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 are server side controls?
what are the events raised in asp.net page life cycle?in which stage view state can be loaded?
What is mvc in angular?
What is server infrastructure & server components?
Why do we need master page in asp.net?
Differentiate between authentication and authorization.
Types of instancing properties and explain each. Tell the difference between multiuse,singleuse and globalmultiuse and which is default ?
What is the maximum amount of memory any single process on windows can address?
How does session work?
Can you use c# without .net?
What is a master page and what does it do?
Which is the parent class of the web server control?
What is the difference between abstract class vs interface? Can give me the real time examples?
Explain code snippet to register exception filters from controller?
How do you implement sql caching in asp.net?