Last active
August 29, 2015 14:12
-
-
Save 0V/a84d629e959e09c75cc5 to your computer and use it in GitHub Desktop.
enum の挙動ちょっと怖い
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
using System; | |
public class Test | |
{ | |
enum T{ | |
A, | |
B, | |
C = A, | |
D, | |
E, | |
} | |
public static void Main() | |
{ | |
Console.WriteLine(T.B == T.A); | |
Console.WriteLine(T.B == T.B); | |
Console.WriteLine(T.B == T.C); | |
Console.WriteLine(T.B == T.D); | |
Console.WriteLine(T.B == T.E); | |
Console.WriteLine((int)T.A); | |
Console.WriteLine((int)T.B); | |
Console.WriteLine((int)T.C); | |
Console.WriteLine((int)T.D); | |
Console.WriteLine((int)T.E); | |
} | |
} | |
/*************************************************** | |
[OUTPUT] | |
False | |
True | |
False | |
True | |
False | |
0 | |
1 | |
0 | |
1 | |
2 | |
**************************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment