C#中Char.IsDigit()和Char.IsNumber之间的区别 [英] Difference between Char.IsDigit() and Char.IsNumber in C#

查看:132
本文介绍了C#中Char.IsDigit()和Char.IsNumber之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


C#中Char.IsDigit()和Char.IsNumber有什么区别.
我在MSDN上得到了理论上的区别.
请为我提供一些示例代码,这些代码将清楚地突出显示差异.

Hi,
What is the difference between Char.IsDigit() and Char.IsNumber in C#.
I got the theoretical difference on MSDN.
Kindly provide me some sample code that will highlight the difference clearly.

推荐答案

MSDN确实非常清楚地说明了这一点. IsDigit仅适用于0-9. IsNumber允许其他数字值,例如小数.
MSDN does spell it out very clearly. IsDigit only works with 0-9. IsNumber allows other number values such as fractions.
string numbers = "0123456789¼½¾";
for (int i = 0; i < numbers.Length; i++)
    {
    char c = numbers[i];
    Console.WriteLine("{0}: IsNumber({1}), IsDigit({2})", c, Char.IsNumber(c), Char.IsDigit(c));
    }


这篇关于C#中Char.IsDigit()和Char.IsNumber之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆