Answer Posted / bhagyesh
class A
{
public A()
{
};
public int i;
}
class TestPerson
{
static void Main()
{
A a = new A();
A b;
a.i =5;
b=a; // not a deep copy
b.i = a.i+6;
}
}
here a.i=11 and b.i = 11 because a and b both refer same
instance of object
Deep copy would be implemented in c# using copy construction
class A
{
public A()
{
};
public A(A previouscopy)
{
i = previouscopy.i;
};
public int i;
}
class TestPerson
{
static void Main()
{
A a = new A();
a.i =5;
// Create another new object, copying a.
A b = new A(a); // Deep copy using copy constructor
b.i = a.i+6;
}
}
here a.i=5 and b.i = 11 because a and b both refer it's own
instance of object
| Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
Can we have multiple web config files for an asp.net application?
What is the postback property in asp.net?
What is Model-View-View Model?
What is the parent class of all web server control?
What are validators and list some validators of asp.net?
How many types of validation are there?
What are the different method of navigation in asp.net?
What are the different kinds of assemblies?
Which protocol is used to call a web service?
Name the namespace which is used by ado.net?
How do you sign out from forms authentication?
What is full trust in asp.net?
Can we set which type of comparison we want to perform by the CompareValidator control?
What are sql notifications and sql invalidations?
What is the purpose of master page?