title: Anyone know a quick way to get to custom attributes on an enum value?
body: <p>This is probably best shown with an example. I have an enum with attributes:</p>
  
  <pre><code>public enum MyEnum {
  
      [CustomInfo("This is a custom attrib")]
      None = 0,
  
      [CustomInfo("This is another attrib")]
      ValueA,
  
      [CustomInfo("This has an extra flag", AllowSomething = true)]
      ValueB,
  }
  </code></pre>
  
  <p>I want to get to those attributes from an instance:</p>
  
  <pre><code>public CustomInfoAttribute GetInfo( MyEnum enumInput ) {
  
      Type typeOfEnum = enumInput.GetType(); //this will be typeof( MyEnum )
  
      //here is the problem, GetField takes a string
      // the .ToString() on enums is very slow
      FieldInfo fi = typeOfEnum.GetField( enumInput.ToString() );
  
      //get the attribute from the field
      return fi.GetCustomAttributes( typeof( CustomInfoAttribute  ), false ).
          FirstOrDefault()        //Linq method to get first or null
          as CustomInfoAttribute; //use as operator to convert
  }
  </code></pre>
  
  <p>As this is using reflection I expect some slowness, but it seems messy to convert the enum value to a string (which reflects the name) when I already have an instance of it.</p>
  
  <p>Does anyone have a better way?</p>