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 best Macanism to clear the Cache in asp.net

1212


What is the function of the ViewState property?

1032


Differences between “dataset” and “datareader”.

1039


How do u declare static variable and how it is declared and what is its lifetime?

1024


Contrast oop and soa. What are tenets of each16. How does the xmlserializer work? What acl permissions does a process using it require?

979


Explain the features that make asp.net more used framework? : asp.net mvc

932


What is sql data source control in asp.net?

1047


In which situation can you not use a viewstate?

951


Can we have a web application running without web.config file?

984


code for "For every 5days system has to create 1text file with the corresponding date and it has to store in c-drive" by using web applications

1851


What permissions do asp.net applications posses by default?

1071


What are demand-paging and pre-paging?

993


How Session outproc in Sqlserver stored?

2748


Can we create a multiple user simultaneously ?

1120


How do u optimize a query in asp.net?

999