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 a generic class?
how to stored and retrive video in Sql server using asp.net c#......?
What is property in c#?
What is difference between ienumerable and list?
What are methods in C#?
Is c# different than c++?
Explain the difference between directcast and ctype.
What is string literal in c#?
How many types of inheritance are there in c#?
What are the advantages of using c#?
What are collection classes?
Explain how do you debug an asp.net web application?
What is private variable?
What is an int in c#?
How assembly versioning in .NET prevent DLL Hell problem?