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 list immutable in c#?
What is the delegates in c#?
What is a value type in c#?
Explain what is copy constructor?
What do you mean by directing?
What are the differences between value types and reference types?
Can list contain duplicates c#?
Illustrate the differences between the system.array.copyto() and system.array.clone()?
What is method and function in c#?
What are the different types of comments in c#?
Write a program to create a user control with name and surname as data members and login as method and also the code to call it. (Hint use event delegates) Practical Example of Passing an Events to delegates
What is the execution entry point for a c# console application?
What is the difference between static and private constructor in c#?
Can the nested class access, the containing class. Give an example?
Explain how do I convert a string to an int in c#?