Is string reference type / value type?

Answer Posted / ak

How do you explain this then?

public void MyTest()
{
Program myClass = new Program();
myClass.value = 1;
Console.Out.WriteLine(myClass.value.ToString
()); //1
Program newClass = myClass;

newClass.value = 2;
Console.Out.WriteLine(myClass.value.ToString
()); //2


myClass.strvalue = new String("1".ToCharArray
());

Console.Out.WriteLine(myClass.strvalue); //1
newClass.strvalue = myClass.strvalue;

newClass.strvalue = "2";
Console.Out.WriteLine(myClass.strvalue); //2
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is data types in c#?

524


What are properties in C#?

544


C# called c sharp why?

554


What is check/uncheck?

603


Can scriptable objects have methods?

500






Is c# and .net same?

494


How do you serialize in c#?

474


What are the basic string operations? Explain.

514


Is c# queue thread safe?

502


What is ildasm and obfuscator in net?

546


What is dataset and dataadapter in c#?

500


What is int32 in c#?

505


What is the difference between proc. Sent by val and by sub?

483


What are constants in c#?

566


How many types of variables are there in c#?

528