Skip to content

Instantly share code, notes, and snippets.

@serhatates
Last active July 18, 2018 10:56
Show Gist options
  • Save serhatates/44e811d4b81c2d3805c070fd818d6d06 to your computer and use it in GitHub Desktop.
Save serhatates/44e811d4b81c2d3805c070fd818d6d06 to your computer and use it in GitHub Desktop.
public static class ListExtension
{
public static List<T> CloneList<T>(this List<T> list, List<T> oldlist)
{
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
formatter.Serialize(stream, oldlist);
stream.Position = 0;
return (List<T>)formatter.Deserialize(stream);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment