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
What is the main difference between Asp.net and Vb.net?
What is a viewstate?
Define a static class?
Why would anyone need to implement their own hashtable or linked list?
What is caching? What are different ways of caching in asp.net?
Which methods validate all the controls on a page?
What is difference between rest and soap?
What is the difference between cookie and session?
How do you hide the columns?
How to disable disable browser's Back button in asp.net (JavaScript)?
What does session_start () do?
If 200 is for all successful operation then why do we have 201 response codes?
Define web.config in .net?
How to Insert/Add in ASPXgridview
Define the term Web Garden?