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
What is data types in c#?
What are properties in C#?
C# called c sharp why?
What is check/uncheck?
Can scriptable objects have methods?
Is c# and .net same?
How do you serialize in c#?
What are the basic string operations? Explain.
Is c# queue thread safe?
What is ildasm and obfuscator in net?
What is dataset and dataadapter in c#?
What is int32 in c#?
What is the difference between proc. Sent by val and by sub?
What are constants in c#?
How many types of variables are there in c#?