Created
October 3, 2012 10:21
-
-
Save jonelf/3826257 to your computer and use it in GitHub Desktop.
Enums in C#
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
class EnumTest | |
{ | |
public enum Cities { AnkhMorpork = 1, Ampridatvir, Lankhmar }; | |
public Cities cities { get; set; } | |
public void WriteCities() | |
{ | |
Cities test = (Cities)4711; | |
Console.WriteLine(test); | |
Console.WriteLine(cities); | |
Console.ReadKey(); | |
} | |
} | |
// Somewhere else | |
new EnumTest().WriteCities(); | |
// Does it compile? | |
// Any runtime errors? | |
// If not, what's the output? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment