C# int 到 Flag Enum
可能的重复:
C# int 到 enum 转换
是否可以以某种方式将 int 转换为标志组合枚举?那么,是否
[Flags]
public enum Foo {a = 0x80,
b = 0x40,
c = ...,
...
h = 0x1,
i = 0};
可以(或以某种方式可能)使
Foo fooInstance = (Foo)6;
fooInstance 变为 00000110 ?
谢谢!
Possible Duplicate:
C# int to enum conversion
Is it somehow possible to convert an int to a flag combination enum? So, if
[Flags]
public enum Foo {a = 0x80,
b = 0x40,
c = ...,
...
h = 0x1,
i = 0};
is it OK (or somehow possible) to do
Foo fooInstance = (Foo)6;
so that fooInstance
would be 00000110?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。
效果很好。标记属性与否。
Yes.
That works just fine. Flags attribute or not.