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 the difference between asp.net and mvc?

1120


What is full form of asp.net?

1018


Will the asp.net validators run in server side or client side?

1144


Is data edited in the Repeater control?

1043


What is session object? Describe in detail.

1020


How you can access the values from the Repeater control in ASP.NET?

1072


How do sessions work?

948


How do u optimize a query in asp.net?

1007


What parameters can you pass in the url of the api?

1117


What is data reader in asp.net?

1159


What is active web pages?

960


What is ashx file in asp.net?

1064


Explain difference between dataset and datareader?

1052


Why do we use sessions?

1001


Why is global asax is used?

1031