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
What is c sharp used for?
Explain inheritance in c#?
When do you generally use a class over a struct?
What is the difference between ref & out parameters in c#?
What is garbage collection? How to force garbage collector to run?
Why are local variables stored in stack?
Do void methods have parameters?
How many types of inheritance are there in c#?
How much time will it take to learn unity?
What is a boolean c#?
Write a C# program to find the Factorial of n
Explain deadlock?
What is a private method in c#?
What are predicates in c#?
What is concatenation and when should it be used?