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 are interfaces in c#?
What is a statement c#?
In how many ways you can overload a method?
Define c# delegate?
What is the purpose of namespace in c#?
Is php easier than c#?
Can interface inherit class in c#?
Can we overload indexer in c#?
What is the difference between continue and break statement?
Is c sharp open source?
What are different types of classes in c#?
What are desktop applications examples?
What is binary search tree in data structure?
Differentiate between method overriding from method overloading with its functionality?
Define Virtual folder?