什么是[标记]属性真的? [英] What Does the [Flags] Attribute Really Do?
问题描述
这是什么应用 [国旗]
真的?
What does applying [Flags]
really do?
我知道它会修改 Enum.ToString $ C $的行为ç
>,但它做什么吗? (如不同的编译器或运行时的行为,等等。)
I know it modifies the behavior of Enum.ToString
, but does it do anything else? (e.g. Different compiler or runtime behavior, etc.)
修改:是的,我知道,它的文件的事实,枚举拟用作按位标志,而且它更符合逻辑的应用它比特标志。我问更多具体的行为改变,虽然,不是一般的编程实践。
Edit: Yeah, I'm aware that it documents the fact that the enum is intended to be used as bitwise flags, and that it's more logical to apply it to bit flags. I was asking more about concrete behavior changes though, not general programming practices.
推荐答案
From an MSDN article:
有有趣的是,当 标志被指定,分析和格式化 方法采用先进的功能。
It is interesting to note that when Flags is specified, Parse and Format methods feature advanced capabilities.
同样,Parse方法可以 成功地解析一个逗号分隔 字符串就像刚领进一 正确的数值。
Likewise, the Parse method can successfully parse a comma-separated string like the one just shown into the proper numeric value.
这篇关于什么是[标记]属性真的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!