using System.Text.RegularExpressions;
///
/// 判断字符串是否是int/double
///
public static bool IsIntOrDouble(string strNumber)
{
Regex objNotNumberPattern = new Regex("[^0-9.-]");
Regex objTwoDotPattern = new Regex("[0-9][.][0-9][.][0-9]");
Regex objTwoMinusPattern = new Regex("[0-9][-][0-9][-][0-9]");
const string strValidRealPattern = “^([-]|[.]|[-.]|[0-9])[0-9][.][0-9]+
"
;
c
o
n
s
t
s
t
r
i
n
g
s
t
r
V
a
l
i
d
I
n
t
e
g
e
r
P
a
t
t
e
r
n
=
"
(
[
−
]
∣
[
0
−
9
]
)
[
0
−
9
]
∗
"; const string strValidIntegerPattern = "^([-]|[0-9])[0-9]*
";conststringstrValidIntegerPattern="([−]∣[0−9])[0−9]∗”;
Regex objNumberPattern = new Regex("(" + strValidRealPattern + “)|(” + strValidIntegerPattern + “)”);
return !objNotNumberPattern.IsMatch(strNumber) &&
!objTwoDotPattern.IsMatch(strNumber) &&
!objTwoMinusPattern.IsMatch(strNumber) &&
objNumberPattern.IsMatch(strNumber);
}