Using .Net, how can I determine if a type is a Numeric ValueType?
Posted
by Nescio
on Stack Overflow
See other posts from Stack Overflow
or by Nescio
Published on 2008-09-23T22:50:40Z
Indexed on
2010/04/24
3:03 UTC
Read the original article
Hit count: 231
.NET
|reflection
Title says it all...
But here's an example:
Dim desiredType as Type
if IsNumeric(desiredType) then ...
EDIT: I only know the Type, not the Value as a string.
Ok, so unfortunately I have to cycle through the TypeCode.
But this is a nice way to do it:
if ((desiredType.IsArray))
return 0;
switch (Type.GetTypeCode(desiredType))
{
case 3:
case 6:
case 7:
case 9:
case 11:
case 13:
case 14:
case 15:
return 1;
}
;return 0;
© Stack Overflow or respective owner