?

Log in

Previous Entry | Next Entry

string str = ".NET interview questions"; // Instance 1
string str1 = ".NET  interview questions"; // points to same Instance 1   


No, the above code will not create multiple instances but rather they will point to the same memory instance. If the compiler finds the same value in memory he points the variable to the same instance rather than creating a new one.


The below two code snippets will create multiple memory instances of the variable.

string str = ".NET interview questions"; // Instance 1
string str1 = ".NET  interview questions"; // points to different instances.

string str = ".NET interview questions"; // Instance 1
string str1 = "c# interview questions"; // points to different instances


You can check if they point to the same memory instance or multiple instances by using “ReferenceEqual” which belongs to “object” type. It returns true if the objects point to the same instance.

object.ReferenceEquals(str, str1);


You can also visit our site for more .NET interview question with answers at www.questpond.com

 You can also see this link c# interview question video: - What kind of questions are asked in .NET interviews?


Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

March 2017
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Powered by LiveJournal.com