Created
November 10, 2014 10:21
-
-
Save hsinjungwu/b83b508bcb213474b0d9 to your computer and use it in GitHub Desktop.
c# Example
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
| //ref : http://stackoverflow.com/a/105402 | |
| using System; | |
| public class CSharpLab | |
| { | |
| public enum myColor | |
| { | |
| gray = 0, | |
| grey = 0, | |
| black, | |
| white | |
| } | |
| public static void Test() | |
| { | |
| foreach (myColor c in (myColor[]) Enum.GetValues(typeof(myColor))) | |
| Console.WriteLine(c.ToString()); | |
| // output : grey, grey, black, white | |
| foreach (string name in Enum.GetNames(typeof(myColor))) | |
| Console.WriteLine(name); | |
| // output : gray, grey, black, white | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment