How can we extend all enum type?
I want to extend all enum type with a new method called "ToStringConstant". This method will return the integer value as String. Here is what I have so far, but compilator won't allow enum in the where clause.
public static string ToStringConstant<T>(this T EnumVar) where T : enum
{
return ((int)EnumVar).ToString();
}
Example :
public enum Example
{
Example = 0
}
void Method()
{
Example var = Example.Example;
var.ToString();//Return "Example"
var.ToStringConstant();//Return "0"
}