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 session in web technology?
Explain what are the advantages of asp.net mvc framework? : asp.net mvc
What is boxing and unboxing in asp.net?
Which is faster viewbag or viewdata?
How do I create a web form?
In the Repeater control which way you can edit?
What are the advantages of Web API?
Write a code snippet to implement the indentation in json in web api.
What is caching in asp.net?
What is the size of Get method and how much data it can store?
What is the difference between globalization and localization?
How to reduce the width of textbox in editcommandcolumn of datagrid?
Describe the diffeerence between inline and code behind - which is best in a loosely coupled solution?
What is a session in programming?
What symbol specifies the beginning of a query string?