Is string reference type / value type?
Answer Posted / who am i
how do you explain this?
private void MyTest()
{
MyClass myClass = new MyClass();
myClass.value = 1;
MessageBox.Show(myClass.value.ToString()); //1
MyClass newClass = myClass;
newClass.value = 2;
MessageBox.Show(myClass.value.ToString()); //2
String myStr = new String("1".ToCharArray());
MessageBox.Show(myStr); //1
String newStr = myStr;
newStr = "2";
MessageBox.Show(myStr); //1 -- Shouldn't it
display 2???
}
public class MyClass
{
public int value=0;
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Is int an object in c#?
Is c# dictionary a hash table?
What is different between Static Constructor and Private Constructor?
How can you read 3rd line from a text file?
How do I start a program in c#?
How does dll hell solve in .net?
What is yield in c#?
Write a short note on interface?
What are actions in c#?
What is super class in c#?
What is arraylist class in c#?
What is the difference between a class and an object c#?
Can we overload the main method in c#?
List the difference between the virtual method and the abstract method?
What is dll file in c#?