public class MyFunkyAttribute : Attribute
public MyFunkyAttribute(MyColor color)
[MyFunky(MyColor.Orange)]
[MyFunky(MyColor.Yellow)]
public static class MyExteions
public static MyColor GetColor(this MyFruit fruit)
var type = fruit.GetType();
var memInfo = type.GetMember(fruit.ToString());
var attributes = memInfo[0].GetCustomAttributes(typeof (MyFunkyAttribute), false);
if (attributes.Length > 0)
return ((MyFunkyAttribute)attributes[0]).Color;
throw new InvalidOperationException("blah");
public static void Main()
var someFruit = MyFruit.Apple;
var itsColor = someFruit.GetColor();
Console.WriteLine("Fruit = " + someFruit + ", Color = " + itsColor);