Created
January 2, 2013 23:23
-
-
Save gogsbread/4439300 to your computer and use it in GitHub Desktop.
Basic TypeDescriptor example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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