ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  ASP.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
How would one do a deep copy in .NET?
 Question Submitted By :: .NetGuru
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How would one do a deep copy in .NET?
Answer
# 1
Two or more pointers have their own Data.
class A
{
string c;
}
A a;
B b;
a=b;//deep copy
 
Is This Answer Correct ?    2 Yes 17 No
Kavita
 
  Re: How would one do a deep copy in .NET?
Answer
# 2
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 ?    4 Yes 1 No
Bhagyesh
 
 
 
  Re: How would one do a deep copy in .NET?
Answer
# 3
In C# if u want to deep allocation, u can used 
serialization that is use ISerializable
for shallow copy u can use cloning, that is use Iclonable 
interface
 
Is This Answer Correct ?    4 Yes 2 No
Pramod Nikumbh
 
  Re: How would one do a deep copy in .NET?
Answer
# 4
public static T DeepCopy<T>(T obj)
        {
            object result = null;

            using (var ms = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(ms, obj);
                ms.Position = 0;

                result = (T)formatter.Deserialize(ms);
                ms.Close();
            }

            return (T)result;
        }
 
Is This Answer Correct ?    0 Yes 0 No
Rad
 

 
 
 
Other ASP.NET Interview Questions
 
  Question Asked @ Answers
 
How do you relate an aspx page with its code behind page ? Accenture3
How do we invoke queries from the application? Microsoft2
Is it possible to use two versions of assembly at the same time?If possible explain with code? Tech-Mahindra3
how can i inharit multiple classes?  1
About Global .asax ? Satyam5
What?s a bubbled event? Visual-Soft5
what is the difference between this.controls and page.form1.controls and me.controls? FactorH2
How do you manage session in ASP and ASP.NET ? Microsoft1
How to migrate from sqlserver 2005 to sql server 2000 (every one know reverse process of that ) Cap-Gemini1
what is manifest? Microsoft3
What are the major differences between asp.net1.1 and asp.net 2.0? CTS7
ASP.NET uses event driven programming model.Justify.  1
what are the attributes of sitemapnode? Satyam3
What is dataset ? Infosys10
How to write unmanaged code and how to identify whether the code is managed / unmanaged ? Accenture1
What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?  6
How do you validate the controls in an ASP .NET page?  2
difference between gridview,data list and repeater control Olive-Tech4
What are different ASP.NET Web Forms with the technology different from though ASP (1.0-3.0)?  1
I am using a range validator and want to use dd mm yyyy format for accepting dates. I get a fairly generic "can't do that" type exception when I use this format for setting the minValue or maxValue properties for the range validator. How can I force it to accept my format? FutureTech1
 
For more ASP.NET Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com