Last active
August 29, 2015 14:23
-
-
Save xmfcx/be93511b955d439c54cb to your computer and use it in GitHub Desktop.
I want Class to remember the old values but it updates them :(
This file contains 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
class TheClass | |
{ | |
public int Val1; | |
public TheClass Old; | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
TheClass aClass = new TheClass(); | |
aClass.Val1 = 5; | |
aClass.Old = aClass; | |
aClass.Val1 = 10; | |
Console.WriteLine(aClass.Old.Val1); | |
//Prints 10, not 5:( | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment