-2

Sorry for the silly question, but I came across the following C# code and I'm wondering what the [Flags] portion is and what it does.

[Flags]
public enum UserFlags
{
     //...
}

Thank you in advance.

Shadox
  • 19
  • 1
  • 5

1 Answers1

0

It's a class attribute. There are also method attributes for example.

You can even write your own

They are usually used to define meta information or behaviour about a class or method and can be read using reflection.

ZoolWay
  • 5,411
  • 6
  • 42
  • 76