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


Please Help Members By Posting Answers For Below Questions

What is the use of parse in c#?

455


Can constructor be protected?

467


Is array reference type in c#?

490


What is the relationship between a process, application domain, and application?

502


What does using do in c#?

517






Difference between value and reference type.

513


What are events in C#?

560


How are methods overloaded?

544


How many bytes is a long c#?

463


Explain dataset.acceptchanges method in .net?

545


For read-only operation which property you have to designated?

558


What is the boxing and unboxing in c#?

502


Is functional interface runnable?

511


Can int be null in c#?

501


Is learning c# hard?

510