[Flags]属性真的做了什么? [英] What Does the [Flags] Attribute Really Do?

查看:175
本文介绍了[Flags]属性真的做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用 [Flags] 真的吗?

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文章

$ b $有趣的是,当指定
Flags时,Parse和Format
方法具有高级功能。

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.

这篇关于[Flags]属性真的做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆