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
In C#, explain the difference between overloading and overriding.
Define clr in .net?
What is private class in c#?
What is Reflection in .NET? Namespace? How will you load an assembly which is not referenced by current assembly?
What is the difference between hashtable and dictionary in c#?
What does f mean in c#?
What does async mean in c#?
Is clr a compiler?
Can we have 2 main methods in c#?
Do unused Namespaces in c# affect run-time performance?
What is the c# equivalent of c++ catch (...), Which was a catch-all statement for any possible exception?
Can we declare private class in c#?
Explain anonymous type in c#?
What is JIT (just in time)? how it works?
Can a sealed class be used as a base class?