DotNet Programming World

Thursday, November 10, 2011

GetEnumName from Enum type


public static string GetEnumName(this T enumItem)
{
if (enumItem is Enum)
return Enum.GetName(typeof(T), enumItem);
else
throw new InvalidCastException("It is not enum type.");
}

0 Comments:

Post a Comment

<< Home