但这是一个例子:
Dim desiredType as Type
if IsNumeric(desiredType) then ...
Run Code Online (Sandbox Code Playgroud)
编辑:我只知道类型,而不是字符串的值.
好的,不幸的是我必须循环使用TypeCode.
但这是一个很好的方法:
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;
Run Code Online (Sandbox Code Playgroud)