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 the default value of boolean variable?
what is inheritance and an example in vb.net and c# of when you might use it?
What are managed providers?
What is the difference between proc. Sent by val and by sub?
What is .cs file in c#?
What is difference between destructor and finalize?
Explain the difference between a struct and a class?
How do you declare an arraylist?
I was trying to use an out int parameter in one of my functions. How should I declare the variable that I am passing to it?
Explain the importance and use of each, version, culture and publickeytoken for an assembly.
What is inheritance in csharp?
What are the principles of delegation?
Can an interface extend a class c#?
Explain the difference between “as” and “is” operators used in c#?
What is a di class?