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
Is there any sample c# code for simple threading?
How do I develop c# apps?
What is the difference between function and method in c#?
Is string null or empty?
What are jagged arrays used for?
Can firstordefault return null?
What are the types of inheritance in c#?
Explain types of comment in c# with examples
Wcf and what is difference between wcf and web services?
Explain about multithreading?
Why static constructor is parameterless in c#?
What does dbml mean in texting?
What is JIT (just in time)? how it works?
In C#, explain the difference between overloading and overriding.
Why are mutable structs evil?