读取C#中的枚举值

hhh*_*hhh 3 c# enums

我目前正在使用C#中的Enums,我遇到了一个无法修复的问题.我试图"谷歌",但我没有找到任何坚实和快速的东西.

我有一个Enum,看起来像这样:

public enum Test {
   Hello = 1234,
   AnotherValue = 382
}
Run Code Online (Sandbox Code Playgroud)

到目前为止看起来合法 现在为了测试目的,我尝试了以下的事情:

int ToCheck = 382;
if(ToCheck == Test.Hello) { ... } // <-- that is the part which won't work.
Run Code Online (Sandbox Code Playgroud)

它怎么看起来正确?

感谢先进的帮助.

Pau*_*ing 10

if(ToCheck == (int)Test.Hello)
Run Code Online (Sandbox Code Playgroud)

要么

if((Test)ToCheck == Test.Hello)
Run Code Online (Sandbox Code Playgroud)