Created
July 28, 2013 22:05
-
-
Save thomaslevesque/6100447 to your computer and use it in GitHub Desktop.
Proof that enum types are mutable
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
var field = typeof(DayOfWeek).GetField("value__"); | |
var d = DayOfWeek.Monday; | |
Console.WriteLine (d); | |
TypedReference r = __makeref(d); | |
field.SetValueDirect(r, 4); | |
Console.WriteLine (d); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment