Is there a way to determine whether or not a given .Net Type is a number? For example: System.UInt32/UInt16/Double are all numbers. I want to avoid a long switc
You could use Type.IsPrimitive and then sort out the Boolean and Char types, something like this:
bool IsNumeric(Type type)
{
return type.IsPrimitive && type!=typeof(char) && type!=typeof(bool);
}
EDIT: You may want to exclude the IntPtr and UIntPtr types as well, if you don't consider them to be numeric.