檢查typeof()是否在數學上可用(數字)的最簡單方法是什麼?typeof()檢查數字值
做我需要使用TryParse method或通過此檢查:
if (!(DC.DataType == typeof(int) || DC.DataType == typeof(double) || DC.DataType == typeof(long) || DC.DataType == typeof(short) || DC.DataType == typeof(float)))
{
MessageBox.Show("Non decimal data cant be calculated");
return;
}
,如果有一個更簡單的方法來做到這一點,你可以自由地提出
相關:http://stackoverflow.com/questions/828807/what-is-the-base-class-for-c-sharp-numeric-value-types – 2012-01-12 13:39:44
「數學上可用」是什麼意思?對於例子來說,雙數組是數學上可用的嗎?我覺得是這樣的。 – 2012-01-12 13:39:53
[使用.Net,我怎樣才能確定一個類型是否是一個Numeric ValueType?](http://stackoverflow.com/questions/124411/using-net-how-can-i-determine-if-a -type-is-a-numeric-valueetype) – 2012-01-12 13:40:34