C# – What Does the [Flags] Attribute Do?

.netbitflagsc++enumsflags

What does applying [Flags] really do?

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.

Best Answer

From an MSDN article:

It is interesting to note that when Flags is specified, Parse and Format methods feature advanced capabilities.

Likewise, the Parse method can successfully parse a comma-separated string like the one just shown into the proper numeric value.

Related Question