.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

Why don't we use new operator while initializing a string ?

Posted By :Ravi Ranjan Kumar     Posted Date :June 16, 2011    Points :40   Category :C# 
Strings are immutable reference types. There's the ldstr IL instruction which allows pushing a new object reference to a string literal. So when you write:

string a = "abc";
The compiler tests if the "abc" literal has already been defined in the metadata and if not declare it. Then it translates this code into the following IL instruction:

ldstr "abc"
Which basically makes the a local variable point to the string literal defined in the metadata.

You can also find related Interview Question to Why don''t we use new operator while initializing a string ?  below: 

To create a string literal exclude escape sequence

@string. With adding @ at the beginning you can escape literal (More...)

String is an...........

String is an Object Type. where other data types are reference type in .NET (More...)

Where do you store connection string?

Database connection string can be stored in the web config file.
The connection string can be stored in the WEB.Config file under
element. (More...)

What does connection string consist of?

The connection string consists of the following parts:
In general:

Server: Whether local or remote.

Uid: User Id (sa-in sql server)

Password: The required password to be filled-in here

Database: The database name. (More...)

Difference between String.Empty and ""

The main difference is lies on memory management.

String.Empty will not create any object of string where as "" (Double Quote or Empty Quote) will create a new object in the memory for the checking the objects. (More...)

What does AddressOf operator do in background ?

The AddressOf operator creates a delegate object to the BackgroundProcess method. A delegate within VB.NET is a type-safe, object-oriented function pointer. After the thread has been instantiated, you begin the execution of the code by calling the Start() method of the thread. (More...)

How do I convert a numeric type to a string?

Call Sytem.Object.ToString(). For example, if the variable count is an integer, write the following:
string text = count.ToString(); (More...)

How you will write a Connection String in web.Config fiel?

Ans) Then write below lines of code:

add name="sqlconnectionstring" connectionString="Data Source=INTHIYAAZ;Initial Catalog=DB;User ID=sa;Password=sa" />

What's the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it's being operated on, a new instance is created. (More...)

To perform asynchronous data access, what must be added to the connection string?

Select Correct Answer.

1. BeginExecute=true
2. MultiThreaded=true
3. MultipleActiveResultSets=true
4. Asynchronous=true

Correct Answer:
4. Asynchronous=true (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend