Skip to content

Instantly share code, notes, and snippets.

@gogsbread
Created January 2, 2013 23:23
Show Gist options
  • Save gogsbread/4439300 to your computer and use it in GitHub Desktop.
Save gogsbread/4439300 to your computer and use it in GitHub Desktop.
Basic TypeDescriptor example
using System;
using System.ComponentModel;
namespace dotNetPlayGround
{
public enum DataType : int
{
None = 0,
[Description("A")]
Alpha = 1,
[Description("N")]
Numeric,
[Description("AN")]
AlphaNumeric,
[Description("D")]
Date
}
class TypeDescriptor
{
public static void Main()
{
AttributeCollection col = System.ComponentModel.TypeDescriptor.GetAttributes(typeof(DataType));
DescriptionAttribute myAttribute = (DescriptionAttribute)col[typeof(DescriptionAttribute)];
Console.WriteLine(myAttribute.Description);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment