Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How would one do a deep copy in .NET?

Answer Posted / rad

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 ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sta?

1040


What is the file extension of web service?

1054


What is a session http?

968


What ports must be open for DCOM over a firewall? What is the purpose of Port 135?

2445


What is Pre-Render event in ASP.NET?

1164


What is Web Server Control Templates.?

1106


What is viewstate? What does the “enableviewstate” property do?

982


Is asp.net and .net same?

1015


What is the mvc model?

1062


Let's say I have an existing application written using vb6 and this application utilizes windows 2000 com+ transaction services. How would you approach migrating this application to.net?

954


What’s difference between “optimistic” and “pessimistic” locking?

1125


What are validator? How do you disable them?

1203


How many web config files can be created for an application?

906


Explain the page lifecycle of an asp.net mvc? : asp.net mvc

930


Which is the parent class of the ASP.NET server control?

1105