Skip to content

Instantly share code, notes, and snippets.

@xmfcx
Created June 24, 2015 10:55
Show Gist options
  • Save xmfcx/cd64786a03bc76468f01 to your computer and use it in GitHub Desktop.
Save xmfcx/cd64786a03bc76468f01 to your computer and use it in GitHub Desktop.
class TheClass
{
public int Val1;
public TheClass Old;
public void Remember()
{
Old = (TheClass)MemberwiseClone();
}
}
internal class Program
{
private static void Main(string[] args)
{
TheClass aClass = new TheClass();
aClass.Val1 = 5;
aClass.Remember();
aClass.Val1 = 10;
Console.WriteLine(aClass.Old.Val1);
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment