Skip to content

Instantly share code, notes, and snippets.

@0V
Last active August 29, 2015 14:12
Show Gist options
  • Save 0V/a84d629e959e09c75cc5 to your computer and use it in GitHub Desktop.
Save 0V/a84d629e959e09c75cc5 to your computer and use it in GitHub Desktop.
enum の挙動ちょっと怖い
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