Skip to content

Instantly share code, notes, and snippets.

@TatsuyaOGth
Created September 15, 2021 04:44
Show Gist options
  • Save TatsuyaOGth/6871c16cd488a6be6c39e10f3ab2ab5b to your computer and use it in GitHub Desktop.
Save TatsuyaOGth/6871c16cd488a6be6c39e10f3ab2ab5b to your computer and use it in GitHub Desktop.
C# Utilities
public static T DeepCopy<T>(T src)
{
using (var stream = new MemoryStream())
{
var serializer = new XmlSerializer(typeof(T));
serializer.Serialize(stream, src);
stream.Seek(0, SeekOrigin.Begin);
return (T)serializer.Deserialize(stream);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment