Created
September 15, 2021 04:44
-
-
Save TatsuyaOGth/6871c16cd488a6be6c39e10f3ab2ab5b to your computer and use it in GitHub Desktop.
C# Utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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