什么是[标记]属性真的?标记、属性

由网友(七色·°雾霾)分享简介:这是什么应用 [国旗] 真的?What does applying [Flags] really do?我知道它会修改 Enum.ToString ,但它做什么吗? (如不同的编译器或运行时的行为,等等。)I know it modifies the behavior of Enum.ToString, b...

这是什么应用 [国旗] 真的?

What does applying [Flags] really do?

我知道它会修改 Enum.ToString ,但它做什么吗? (如不同的编译器或运行时的行为,等等。)

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.

推荐答案

从 MSDN文章< /一>:

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.