Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A
dotnetinter

.NET interview questions and answers: - Will the below codes create new instances?

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?


Tags: .net and c# interview questions, .net and c# training, .net interview questions and answers, csharp interview questions, information technology questions, programming interview questions
Subscribe

  • How to create an OLAP Cube?

    This article will have no theory rather than it will have only be demonstrating practical step by step in detail included to create SSAS OLAP Cube:…

  • Instrumentation is SSIS using Data Taps

    In this short article we will hover around some important questions related to Instrumentation done in SSIS using Data Taps. We will only discuss…

  • Create job using SQL Server Agent step by step.

    In MSBI while working on SSIS projects we have to run repetitive task which has to carried out daily like running package or to take weekly backup…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments