document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2.  
  3. namespace AttributeDemo
  4. {
  5.     enum Color
  6.     {
  7.         Red = 1,
  8.         Blue = 2,
  9.         Green = 4,
  10.     }
  11.  
  12.     class FooAttribute : Attribute
  13.     {
  14.         public FooAttribute(Color[] colors, string text, bool check, Type type)
  15.         {
  16.             Console.Write("Colors: ");
  17.             foreach (var color in colors)
  18.                 Console.Write(string.Concat(color, " "));
  19.             Console.WriteLine();
  20.  
  21.             Console.WriteLine(text);
  22.             Console.WriteLine(check);
  23.             Console.WriteLine(type);
  24.         }
  25.     }
  26.  
  27.     class Program
  28.     {
  29.         static void Main(string[] args)
  30.         {
  31.             // force call to CustomAttribute ctor.
  32.             typeof (Program).GetMethod("stub").GetCustomAttributes(true);
  33.            
  34.             Console.ReadKey();
  35.         }
  36.  
  37.         [Foo(new Color[] { Color.Blue }, "hello guys", true, typeof(MarshalByRefObject))]
  38.         public static void stub() { }
  39.     }
  40. }
');