I need to have information about maximum value of enum i method with generics..
public static T DoSomething<T>() where T : struct, IConvertible, IComparable, IFormattable
{
T pom1 = Enum.GetValues(typeof(T)).Cast<T>().Max();
...
In pom1 is value of maximum possible value of T (enum) - it works. But when I want to get int from pom1, its problem.
int pom4 = (int)pom1;
I tryied something like this:
int pom4 = (int)(ValueType)pom1;
Still error like "Specific cast is not valid"
Thanks of any help.