IsDigit 与IsNumber 的区别。

 MS 实现的 code

public static bool IsDigit(char c)

{

if (!IsLatin1(c))

{

return (CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.DecimalDigitNumber);

}

return ((c >= '0') && (c <= '9'));

}

   

public static bool IsNumber(char c)

{

if (!IsLatin1(c))

{

return CheckNumber(CharUnicodeInfo.GetUnicodeCategory(c));

}

if (!IsAscii(c))

{

return CheckNumber(GetLatin1UnicodeCategory(c));

}

return ((c >= '0') && (c <= '9'));

}

从上面MS实现的code看, 已经很明显了。 IsNumber 多了一步验证Ascii 码, IsAscii

   

IsDigit: {是否是个十进制数字; 范围 0..9}
IsNumber: {
是否是个数字符号; 范围包括 0..9, 还有 ASCII 码中的 178179185188189190 }

if you input   ¼, ½,¾,²,³,¹ ,  then IsNumber return true.  IsDigit return false.

 

   

ASCII

  

HTML

HTML

  

Dec

Hex

Symbol

Number

Name

 
 

176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191

B0
B1
B2
B3
B4
B5
B6
B7
B8
B9
BA
BB
BC
BD
BE
BF

°
±
²
³
´
µ

·
¸
¹
º
»
¼
½
¾
¿

°
±
&#178;
&#179;
´
µ

·
¸
&#185;
º
»
&#188;
&#189;
&#190;
¿

°
±
²
³
´
µ

·
¸
¹
º
»
¼
½
¾
¿

 

   

   

   

   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值