T
Tariq Ahmad
got this code from codeproject.com, but cant convert it to vb.
can u help please? thnx.
t.
----------------------------------------------------------------------------
-------
Append a Description attribute to each enum entry:
private enum MyColors
{
[Description("yuk!")] LightGreen = 0x012020,
[Description("nice ")] VeryDeepPink = 0x123456,
[Description("so what")] InvisibleGray = 0x456730,
[Description("no comment")] DeepestRed = 0xfafafa,
[Description("I give up")] PitchBlack = 0xffffff,
}To access the description from code, the following function is called:
public static string GetDescription(Enum value)
{
FieldInfo fi= value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
return (attributes.Length>0)?attributes[0].Description:value.ToString();
}
can u help please? thnx.
t.
----------------------------------------------------------------------------
-------
Append a Description attribute to each enum entry:
private enum MyColors
{
[Description("yuk!")] LightGreen = 0x012020,
[Description("nice ")] VeryDeepPink = 0x123456,
[Description("so what")] InvisibleGray = 0x456730,
[Description("no comment")] DeepestRed = 0xfafafa,
[Description("I give up")] PitchBlack = 0xffffff,
}To access the description from code, the following function is called:
public static string GetDescription(Enum value)
{
FieldInfo fi= value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
return (attributes.Length>0)?attributes[0].Description:value.ToString();
}