码迷,mamicode.com
首页 > Windows程序 > 详细

Difference between Char.IsDigit() and Char.IsNumber() in C#

时间:2016-10-27 13:11:54      阅读:337      评论:0      收藏:0      [点我收藏+]

标签:pre   and   over   ret   ascii   nts   action   static   sharp   

http://stackoverflow.com/questions/228532/difference-between-char-isdigit-and-char-isnumber-in-c-sharp

Char.IsDigit() is a subset of Char.IsNumber().

Some of the characters that are ‘numeric‘ but not digits include 0x00b2 and 0x00b3 which are superscripted 2 and 3 (‘²‘ and ‘³‘) and the glyphs that are fractions such as ‘¼‘, ‘½‘, and ‘¾‘.

Note that there are quite a few characters that IsDigit() returns true for that are not in the ASCII range of 0x30 to 0x39, such as these Thai digit characters: ‘?‘ ‘?‘ ‘?‘ ‘?‘ ‘?‘ ‘?‘ ‘?‘ ‘?‘ ‘?‘ ‘?‘.

This snippet of code tells you which code points differ:

static private void test()
{
    for (int i = 0; i <= 0xffff; ++i)
    {
        char c = (char) i;

        if (Char.IsDigit( c) != Char.IsNumber( c)) {
            Console.WriteLine( "Char value {0:x} IsDigit() = {1}, IsNumber() = {2}", i, Char.IsDigit( c), Char.IsNumber( c));
        }
    }
}

 

Difference between Char.IsDigit() and Char.IsNumber() in C#

标签:pre   and   over   ret   ascii   nts   action   static   sharp   

原文地址:http://www.cnblogs.com/chucklu/p/6003157.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!