Defining an attribute type is useless by itself. Sure, you could define attribute types all you want and apply them all you want; but this would just cause additional metadata to be written out to the managed module—the behavior of your application code wouldn’t change.
In Chapter 13, you saw that applying the
Flags attribute to an enumerated type altered the behavior of
Parse methods. The reason these methods behave differently is that they check at run time whether the enumerated type they’re operating on has the
Flags attribute metadata associated with it. Code can look for the presence of attributes using a technology called reflection. I’ll give some brief demonstrations ...