C# 中 Char.IsDigit() 和 Char.IsNumber() 的区别

Posted

技术标签:

【中文标题】C# 中 Char.IsDigit() 和 Char.IsNumber() 的区别【英文标题】:Difference between Char.IsDigit() and Char.IsNumber() in C# 【发布时间】:2010-09-18 17:12:01 【问题描述】:

Char.IsDigit()Char.IsNumber() 在 C# 中的区别是什么?

【问题讨论】:

【参考方案1】:

Char.IsDigit()Char.IsNumber() 的子集。

一些“数字”但不是数字的字符包括上标 2 和 3(“²”和“³”)的 0x00b2 和 0x00b3,以及诸如“¼”、“½”等分数的字形,和“¾”。

请注意,有不少字符IsDigit() 返回true,因为它们不在 0x30 到 0x39 的 ASCII 范围内,例如这些泰语数字字符:'๐' '๑' '๒' '๓ ''๔''๕''๖''๗''๘''๙'。

这段代码的 sn-p 告诉您哪些代码点不同:

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));
        
    

【讨论】:

所以底线,我如何确定一个char是否存在是0123456789之一? @Shimmy 尝试将其解析为 int @shimmy if ("0123456789".Contains(c)) 第一行不是Char.IsNumber(),而不是Char.IsNumeric吗? @BradleyUffner,新程序员可能会在尝试使用双引号而不是单引号作为字符文字时遇到困难。这是代码以防万一有人想要它:character &gt;= '0' &amp;&amp; character &lt;= '9'.【参考方案2】:

我找到了答案:

Char.IsNumber() 判断一个 Char 属于任何数字 Unicode 类别。 这与 IsDigit 形成对比,后者 确定 Char 是否为 radix-10 数字。

有效数字是 以下类别在 UnicodeCategory:

    DecimalDigitNumber 十进制数字字符,即 0 到 9 范围内的字符。由 Unicode 名称“Nd”(数字,十进制数字)表示。值为 8。 LetterNumber 用字母表示的数字,而不是十进制数字,例如罗马数字表示五,即“V”。该指示符由 Unicode 名称“Nl”(数字、字母)表示。值为 9。 OtherNumber 既不是十进制数字也不是字母数字的数字,例如分数 ½。该指示符由 Unicode 名称“否”(数字、其他)表示。值为 10。

结论

Char.IsDigit: 有效数字仅是 DecimalDigitNumber 类别的成员。 Char.IsNumber: 有效号码是 DecimalDigitNumberLetterNumberOtherNumber 类别的成员。

【讨论】:

【参考方案3】:

IsNumber(x) 有时会返回true,因为结果一般人不会认为是数字,这就是原因。

C# 将字符分组到 UnicodeCategory 中,其中数字不属于单一类别,而是 3 个不同类别:

    UnicodeCategory.DecimalDigitNumber

十进制数字字符,即 0 到 0 范围内的字符 9. 由 Unicode 名称“Nd”(数字,十进制数字)表示。值为 8。

    UnicodeCategory.OtherNumber

既不是十进制数字也不是字母数字的数字,例如 例如,分数 1/2。该指标由 Unicode 表示 指定“否”(编号,其他)。值为 10。

    UnicodeCategory.LetterNumber

用字母而不是十进制数字表示的数字,用于 例如,罗马数字表示五,即“V”。指标是 由 Unicode 名称“Nl”(数字、字母)表示。价值 是 9。

任何属于上述之一的内容都将返回trueIsNumber()。因为是IsDigit(),它只会是UnicodeCategory.DecimalDigitNumber

我写了这段代码来表明哪个是哪个:(由于允许的帖子大小,表格未满,但您应该能够生成它,无论如何它仅用于示例目的)

    [Test]
    public void IsNumberTest()
    
        var numberLikes = new[]  UnicodeCategory.DecimalDigitNumber, UnicodeCategory.OtherNumber, UnicodeCategory.LetterNumber ;
        for (var i = 0; i < 0xffff; i++)
        
            var c = Char.ConvertFromUtf32(i).ToCharArray()[0];
            if (numberLikes.Contains(Char.GetUnicodeCategory(c)))
            
                File.AppendAllText("IsNumberLike.txt", string.Format("0,1,2,&#3;,4,5\n", i, c, Char.GetUnicodeCategory(c), i, Char.IsNumber(c), Char.IsDigit(c)));
            
        
    

结果如下所示:如您所见,有些东西不会是“数字”。

+------+----+--------------------+----------+------+-------+
| int |symbol| UnicodeCategory   | html   |IsNumber|IsDigit|
+-------+---+--------------------+----------+------+-------+
|    48 | 0 | DecimalDigitNumber | &#48;    | True | True  |
|    49 | 1 | DecimalDigitNumber | &#49;    | True | True  |
|    50 | 2 | DecimalDigitNumber | &#50;    | True | True  |
|    51 | 3 | DecimalDigitNumber | &#51;    | True | True  |
|    52 | 4 | DecimalDigitNumber | &#52;    | True | True  |
|    53 | 5 | DecimalDigitNumber | &#53;    | True | True  |
|    54 | 6 | DecimalDigitNumber | &#54;    | True | True  |
|    55 | 7 | DecimalDigitNumber | &#55;    | True | True  |
|    56 | 8 | DecimalDigitNumber | &#56;    | True | True  |
|    57 | 9 | DecimalDigitNumber | &#57;    | True | True  |
|   178 | ² | OtherNumber        | &#178;   | True | False |
|   179 | ³ | OtherNumber        | &#179;   | True | False |
|   185 | ¹ | OtherNumber        | &#185;   | True | False |
|   188 | ¼ | OtherNumber        | &#188;   | True | False |
|   189 | ½ | OtherNumber        | &#189;   | True | False |
|   190 | ¾ | OtherNumber        | &#190;   | True | False |
|  1632 | ٠ | DecimalDigitNumber | &#1632;  | True | True  |
|  1633 | ١ | DecimalDigitNumber | &#1633;  | True | True  |
|  1634 | ٢ | DecimalDigitNumber | &#1634;  | True | True  |
|  1635 | ٣ | DecimalDigitNumber | &#1635;  | True | True  |
|  1636 | ٤ | DecimalDigitNumber | &#1636;  | True | True  |
|  1637 | ٥ | DecimalDigitNumber | &#1637;  | True | True  |
|  1638 | ٦ | DecimalDigitNumber | &#1638;  | True | True  |
|  1639 | ٧ | DecimalDigitNumber | &#1639;  | True | True  |
|  1640 | ٨ | DecimalDigitNumber | &#1640;  | True | True  |
|  1641 | ٩ | DecimalDigitNumber | &#1641;  | True | True  |
|  1776 | ۰ | DecimalDigitNumber | &#1776;  | True | True  |
|  1777 | ۱ | DecimalDigitNumber | &#1777;  | True | True  |
|  1778 | ۲ | DecimalDigitNumber | &#1778;  | True | True  |
|  1779 | ۳ | DecimalDigitNumber | &#1779;  | True | True  |
|  1780 | ۴ | DecimalDigitNumber | &#1780;  | True | True  |
|  1781 | ۵ | DecimalDigitNumber | &#1781;  | True | True  |
|  1782 | ۶ | DecimalDigitNumber | &#1782;  | True | True  |
|  1783 | ۷ | DecimalDigitNumber | &#1783;  | True | True  |
|  1784 | ۸ | DecimalDigitNumber | &#1784;  | True | True  |
|  1785 | ۹ | DecimalDigitNumber | &#1785;  | True | True  |
|  1984 | ߀ | DecimalDigitNumber | &#1984;  | True | True  |
|  1985 | ߁ | DecimalDigitNumber | &#1985;  | True | True  |
|  1986 | ߂ | DecimalDigitNumber | &#1986;  | True | True  |
|  1987 | ߃ | DecimalDigitNumber | &#1987;  | True | True  |
|  1988 | ߄ | DecimalDigitNumber | &#1988;  | True | True  |
|  1989 | ߅ | DecimalDigitNumber | &#1989;  | True | True  |
|  1990 | ߆ | DecimalDigitNumber | &#1990;  | True | True  |
|  1991 | ߇ | DecimalDigitNumber | &#1991;  | True | True  |
|  1992 | ߈ | DecimalDigitNumber | &#1992;  | True | True  |
|  1993 | ߉ | DecimalDigitNumber | &#1993;  | True | True  |
|  2406 | ० | DecimalDigitNumber | &#2406;  | True | True  |
|  2407 | १ | DecimalDigitNumber | &#2407;  | True | True  |
|  2408 | २ | DecimalDigitNumber | &#2408;  | True | True  |
|  2409 | ३ | DecimalDigitNumber | &#2409;  | True | True  |
|  2410 | ४ | DecimalDigitNumber | &#2410;  | True | True  |
|  2411 | ५ | DecimalDigitNumber | &#2411;  | True | True  |
|  2412 | ६ | DecimalDigitNumber | &#2412;  | True | True  |
|  2413 | ७ | DecimalDigitNumber | &#2413;  | True | True  |
|  2414 | ८ | DecimalDigitNumber | &#2414;  | True | True  |
|  2415 | ९ | DecimalDigitNumber | &#2415;  | True | True  |
|  2534 | ০ | DecimalDigitNumber | &#2534;  | True | True  |
|  2535 | ১ | DecimalDigitNumber | &#2535;  | True | True  |
|  2536 | ২ | DecimalDigitNumber | &#2536;  | True | True  |
|  2537 | ৩ | DecimalDigitNumber | &#2537;  | True | True  |
|  2538 | ৪ | DecimalDigitNumber | &#2538;  | True | True  |
|  2539 | ৫ | DecimalDigitNumber | &#2539;  | True | True  |
|  2540 | ৬ | DecimalDigitNumber | &#2540;  | True | True  |
|  2541 | ৭ | DecimalDigitNumber | &#2541;  | True | True  |
|  2542 | ৮ | DecimalDigitNumber | &#2542;  | True | True  |
|  2543 | ৯ | DecimalDigitNumber | &#2543;  | True | True  |
|  2548 | ৴ | OtherNumber        | &#2548;  | True | False |
|  2549 | ৵ | OtherNumber        | &#2549;  | True | False |
|  2550 | ৶ | OtherNumber        | &#2550;  | True | False |
|  2551 | ৷ | OtherNumber        | &#2551;  | True | False |
|  2552 | ৸ | OtherNumber        | &#2552;  | True | False |
|  2553 | ৹ | OtherNumber        | &#2553;  | True | False |
|  2662 | ੦ | DecimalDigitNumber | &#2662;  | True | True  |
|  2663 | ੧ | DecimalDigitNumber | &#2663;  | True | True  |
|  2664 | ੨ | DecimalDigitNumber | &#2664;  | True | True  |
|  2665 | ੩ | DecimalDigitNumber | &#2665;  | True | True  |
|  2666 | ੪ | DecimalDigitNumber | &#2666;  | True | True  |
|  2667 | ੫ | DecimalDigitNumber | &#2667;  | True | True  |
|  2668 | ੬ | DecimalDigitNumber | &#2668;  | True | True  |
|  2669 | ੭ | DecimalDigitNumber | &#2669;  | True | True  |
|  2670 | ੮ | DecimalDigitNumber | &#2670;  | True | True  |
|  2671 | ੯ | DecimalDigitNumber | &#2671;  | True | True  |
|  2790 | ૦ | DecimalDigitNumber | &#2790;  | True | True  |
|  2791 | ૧ | DecimalDigitNumber | &#2791;  | True | True  |
|  2792 | ૨ | DecimalDigitNumber | &#2792;  | True | True  |
|  2793 | ૩ | DecimalDigitNumber | &#2793;  | True | True  |
|  2794 | ૪ | DecimalDigitNumber | &#2794;  | True | True  |
|  2795 | ૫ | DecimalDigitNumber | &#2795;  | True | True  |
|  2796 | ૬ | DecimalDigitNumber | &#2796;  | True | True  |
|  2797 | ૭ | DecimalDigitNumber | &#2797;  | True | True  |
|  2798 | ૮ | DecimalDigitNumber | &#2798;  | True | True  |
|  2799 | ૯ | DecimalDigitNumber | &#2799;  | True | True  |
|  2918 | ୦ | DecimalDigitNumber | &#2918;  | True | True  |
|  2919 | ୧ | DecimalDigitNumber | &#2919;  | True | True  |
|  2920 | ୨ | DecimalDigitNumber | &#2920;  | True | True  |
|  2921 | ୩ | DecimalDigitNumber | &#2921;  | True | True  |
|  2922 | ୪ | DecimalDigitNumber | &#2922;  | True | True  |
|  2923 | ୫ | DecimalDigitNumber | &#2923;  | True | True  |
|  2924 | ୬ | DecimalDigitNumber | &#2924;  | True | True  |
|  2925 | ୭ | DecimalDigitNumber | &#2925;  | True | True  |
|  2926 | ୮ | DecimalDigitNumber | &#2926;  | True | True  |
|  2927 | ୯ | DecimalDigitNumber | &#2927;  | True | True  |
|  2930 | ୲ | OtherNumber        | &#2930;  | True | False |
|  2931 | ୳ | OtherNumber        | &#2931;  | True | False |
|  2932 | ୴ | OtherNumber        | &#2932;  | True | False |
|  2933 | ୵ | OtherNumber        | &#2933;  | True | False |
|  2934 | ୶ | OtherNumber        | &#2934;  | True | False |
|  2935 | ୷ | OtherNumber        | &#2935;  | True | False |
|  3046 | ௦ | DecimalDigitNumber | &#3046;  | True | True  |
|  3047 | ௧ | DecimalDigitNumber | &#3047;  | True | True  |
|  3048 | ௨ | DecimalDigitNumber | &#3048;  | True | True  |
|  3049 | ௩ | DecimalDigitNumber | &#3049;  | True | True  |
|  3050 | ௪ | DecimalDigitNumber | &#3050;  | True | True  |
|  3051 | ௫ | DecimalDigitNumber | &#3051;  | True | True  |
|  3052 | ௬ | DecimalDigitNumber | &#3052;  | True | True  |
|  3053 | ௭ | DecimalDigitNumber | &#3053;  | True | True  |
|  3054 | ௮ | DecimalDigitNumber | &#3054;  | True | True  |
|  3055 | ௯ | DecimalDigitNumber | &#3055;  | True | True  |
|  3056 | ௰ | OtherNumber        | &#3056;  | True | False |
|  3057 | ௱ | OtherNumber        | &#3057;  | True | False |
|  3058 | ௲ | OtherNumber        | &#3058;  | True | False |
|  3174 | ౦ | DecimalDigitNumber | &#3174;  | True | True  |
|  3175 | ౧ | DecimalDigitNumber | &#3175;  | True | True  |
|  3176 | ౨ | DecimalDigitNumber | &#3176;  | True | True  |
|  3177 | ౩ | DecimalDigitNumber | &#3177;  | True | True  |
|  3178 | ౪ | DecimalDigitNumber | &#3178;  | True | True  |
|  3179 | ౫ | DecimalDigitNumber | &#3179;  | True | True  |
|  3180 | ౬ | DecimalDigitNumber | &#3180;  | True | True  |
|  3181 | ౭ | DecimalDigitNumber | &#3181;  | True | True  |
|  3182 | ౮ | DecimalDigitNumber | &#3182;  | True | True  |
|  3183 | ౯ | DecimalDigitNumber | &#3183;  | True | True  |
|  3192 | ౸ | OtherNumber        | &#3192;  | True | False |
|  3193 | ౹ | OtherNumber        | &#3193;  | True | False |
|  3194 | ౺ | OtherNumber        | &#3194;  | True | False |
|  3195 | ౻ | OtherNumber        | &#3195;  | True | False |
|  3196 | ౼ | OtherNumber        | &#3196;  | True | False |
|  3197 | ౽ | OtherNumber        | &#3197;  | True | False |
|  3198 | ౾ | OtherNumber        | &#3198;  | True | False |
|  3302 | ೦ | DecimalDigitNumber | &#3302;  | True | True  |
|  3303 | ೧ | DecimalDigitNumber | &#3303;  | True | True  |
|  3304 | ೨ | DecimalDigitNumber | &#3304;  | True | True  |
|  3305 | ೩ | DecimalDigitNumber | &#3305;  | True | True  |
|  3306 | ೪ | DecimalDigitNumber | &#3306;  | True | True  |
|  3307 | ೫ | DecimalDigitNumber | &#3307;  | True | True  |
|  3308 | ೬ | DecimalDigitNumber | &#3308;  | True | True  |
|  3309 | ೭ | DecimalDigitNumber | &#3309;  | True | True  |
|  3310 | ೮ | DecimalDigitNumber | &#3310;  | True | True  |
|  3311 | ೯ | DecimalDigitNumber | &#3311;  | True | True  |
|  3430 | ൦ | DecimalDigitNumber | &#3430;  | True | True  |
|  3431 | ൧ | DecimalDigitNumber | &#3431;  | True | True  |
|  3432 | ൨ | DecimalDigitNumber | &#3432;  | True | True  |
|  3433 | ൩ | DecimalDigitNumber | &#3433;  | True | True  |
|  3434 | ൪ | DecimalDigitNumber | &#3434;  | True | True  |
|  3435 | ൫ | DecimalDigitNumber | &#3435;  | True | True  |
|  3436 | ൬ | DecimalDigitNumber | &#3436;  | True | True  |
|  3437 | ൭ | DecimalDigitNumber | &#3437;  | True | True  |
|  3438 | ൮ | DecimalDigitNumber | &#3438;  | True | True  |
|  3439 | ൯ | DecimalDigitNumber | &#3439;  | True | True  |
|  3440 | ൰ | OtherNumber        | &#3440;  | True | False |
|  3441 | ൱ | OtherNumber        | &#3441;  | True | False |
|  3442 | ൲ | OtherNumber        | &#3442;  | True | False |
|  3443 | ൳ | OtherNumber        | &#3443;  | True | False |
|  3444 | ൴ | OtherNumber        | &#3444;  | True | False |
|  3445 | ൵ | OtherNumber        | &#3445;  | True | False |
|  3664 | ๐ | DecimalDigitNumber | &#3664;  | True | True  |
|  3665 | ๑ | DecimalDigitNumber | &#3665;  | True | True  |
|  3666 | ๒ | DecimalDigitNumber | &#3666;  | True | True  |
|  3667 | ๓ | DecimalDigitNumber | &#3667;  | True | True  |
|  3668 | ๔ | DecimalDigitNumber | &#3668;  | True | True  |
|  3669 | ๕ | DecimalDigitNumber | &#3669;  | True | True  |
|  3670 | ๖ | DecimalDigitNumber | &#3670;  | True | True  |
|  3671 | ๗ | DecimalDigitNumber | &#3671;  | True | True  |
|  3672 | ๘ | DecimalDigitNumber | &#3672;  | True | True  |
|  3673 | ๙ | DecimalDigitNumber | &#3673;  | True | True  |
|  3792 | ໐ | DecimalDigitNumber | &#3792;  | True | True  |
|  3793 | ໑ | DecimalDigitNumber | &#3793;  | True | True  |
|  3794 | ໒ | DecimalDigitNumber | &#3794;  | True | True  |
|  3795 | ໓ | DecimalDigitNumber | &#3795;  | True | True  |
|  3796 | ໔ | DecimalDigitNumber | &#3796;  | True | True  |
|  3797 | ໕ | DecimalDigitNumber | &#3797;  | True | True  |
|  3798 | ໖ | DecimalDigitNumber | &#3798;  | True | True  |
|  3799 | ໗ | DecimalDigitNumber | &#3799;  | True | True  |
|  3800 | ໘ | DecimalDigitNumber | &#3800;  | True | True  |
|  3801 | ໙ | DecimalDigitNumber | &#3801;  | True | True  |
|  3872 | ༠ | DecimalDigitNumber | &#3872;  | True | True  |
|  3873 | ༡ | DecimalDigitNumber | &#3873;  | True | True  |
|  3874 | ༢ | DecimalDigitNumber | &#3874;  | True | True  |
|  3875 | ༣ | DecimalDigitNumber | &#3875;  | True | True  |
|  3876 | ༤ | DecimalDigitNumber | &#3876;  | True | True  |
|  3877 | ༥ | DecimalDigitNumber | &#3877;  | True | True  |
|  3878 | ༦ | DecimalDigitNumber | &#3878;  | True | True  |
|  3879 | ༧ | DecimalDigitNumber | &#3879;  | True | True  |
|  3880 | ༨ | DecimalDigitNumber | &#3880;  | True | True  |
|  3881 | ༩ | DecimalDigitNumber | &#3881;  | True | True  |
|  3882 | ༪ | OtherNumber        | &#3882;  | True | False |
|  3883 | ༫ | OtherNumber        | &#3883;  | True | False |
|  3884 | ༬ | OtherNumber        | &#3884;  | True | False |
|  3885 | ༭ | OtherNumber        | &#3885;  | True | False |
|  3886 | ༮ | OtherNumber        | &#3886;  | True | False |
|  3887 | ༯ | OtherNumber        | &#3887;  | True | False |
|  3888 | ༰ | OtherNumber        | &#3888;  | True | False |
|  3889 | ༱ | OtherNumber        | &#3889;  | True | False |
|  3890 | ༲ | OtherNumber        | &#3890;  | True | False |
|  3891 | ༳ | OtherNumber        | &#3891;  | True | False |
|  4160 | ၀ | DecimalDigitNumber | &#4160;  | True | True  |
|  4161 | ၁ | DecimalDigitNumber | &#4161;  | True | True  |
|  4162 | ၂ | DecimalDigitNumber | &#4162;  | True | True  |
|  4163 | ၃ | DecimalDigitNumber | &#4163;  | True | True  |
|  4164 | ၄ | DecimalDigitNumber | &#4164;  | True | True  |
|  4165 | ၅ | DecimalDigitNumber | &#4165;  | True | True  |
|  4166 | ၆ | DecimalDigitNumber | &#4166;  | True | True  |
|  4167 | ၇ | DecimalDigitNumber | &#4167;  | True | True  |
|  4168 | ၈ | DecimalDigitNumber | &#4168;  | True | True  |
|  4169 | ၉ | DecimalDigitNumber | &#4169;  | True | True  |
|  4240 | ႐ | DecimalDigitNumber | &#4240;  | True | True  |
|  4241 | ႑ | DecimalDigitNumber | &#4241;  | True | True  |
|  4242 | ႒ | DecimalDigitNumber | &#4242;  | True | True  |
|  4243 | ႓ | DecimalDigitNumber | &#4243;  | True | True  |
|  4244 | ႔ | DecimalDigitNumber | &#4244;  | True | True  |
|  4245 | ႕ | DecimalDigitNumber | &#4245;  | True | True  |
|  4246 | ႖ | DecimalDigitNumber | &#4246;  | True | True  |
|  4247 | ႗ | DecimalDigitNumber | &#4247;  | True | True  |
|  4248 | ႘ | DecimalDigitNumber | &#4248;  | True | True  |
|  4249 | ႙ | DecimalDigitNumber | &#4249;  | True | True  |
|  4969 | ፩ | OtherNumber        | &#4969;  | True | False |
|  4970 | ፪ | OtherNumber        | &#4970;  | True | False |
|  4971 | ፫ | OtherNumber        | &#4971;  | True | False |
|  4972 | ፬ | OtherNumber        | &#4972;  | True | False |
|  4973 | ፭ | OtherNumber        | &#4973;  | True | False |
|  4974 | ፮ | OtherNumber        | &#4974;  | True | False |
|  4975 | ፯ | OtherNumber        | &#4975;  | True | False |
|  4976 | ፰ | OtherNumber        | &#4976;  | True | False |
|  4977 | ፱ | OtherNumber        | &#4977;  | True | False |
|  4978 | ፲ | OtherNumber        | &#4978;  | True | False |
|  4979 | ፳ | OtherNumber        | &#4979;  | True | False |
|  4980 | ፴ | OtherNumber        | &#4980;  | True | False |
|  4981 | ፵ | OtherNumber        | &#4981;  | True | False |
|  4982 | ፶ | OtherNumber        | &#4982;  | True | False |
|  4983 | ፷ | OtherNumber        | &#4983;  | True | False |
|  4984 | ፸ | OtherNumber        | &#4984;  | True | False |
|  4985 | ፹ | OtherNumber        | &#4985;  | True | False |
|  4986 | ፺ | OtherNumber        | &#4986;  | True | False |
|  4987 | ፻ | OtherNumber        | &#4987;  | True | False |
|  4988 | ፼ | OtherNumber        | &#4988;  | True | False |
|  5870 | ᛮ | LetterNumber       | &#5870;  | True | False |
|  5871 | ᛯ | LetterNumber       | &#5871;  | True | False |
|  5872 | ᛰ | LetterNumber       | &#5872;  | True | False |
|  6112 | ០ | DecimalDigitNumber | &#6112;  | True | True  |
|  6113 | ១ | DecimalDigitNumber | &#6113;  | True | True  |
|  6114 | ២ | DecimalDigitNumber | &#6114;  | True | True  |
|  6115 | ៣ | DecimalDigitNumber | &#6115;  | True | True  |
|  6116 | ៤ | DecimalDigitNumber | &#6116;  | True | True  |
|  6117 | ៥ | DecimalDigitNumber | &#6117;  | True | True  |
|  6118 | ៦ | DecimalDigitNumber | &#6118;  | True | True  |
|  6119 | ៧ | DecimalDigitNumber | &#6119;  | True | True  |
|  6120 | ៨ | DecimalDigitNumber | &#6120;  | True | True  |
|  6121 | ៩ | DecimalDigitNumber | &#6121;  | True | True  |
|  6128 | ៰ | OtherNumber        | &#6128;  | True | False |
|  6129 | ៱ | OtherNumber        | &#6129;  | True | False |
|  6130 | ៲ | OtherNumber        | &#6130;  | True | False |
|  6131 | ៳ | OtherNumber        | &#6131;  | True | False |
|  6132 | ៴ | OtherNumber        | &#6132;  | True | False |
|  6133 | ៵ | OtherNumber        | &#6133;  | True | False |
|  6134 | ៶ | OtherNumber        | &#6134;  | True | False |
|  6135 | ៷ | OtherNumber        | &#6135;  | True | False |
|  6136 | ៸ | OtherNumber        | &#6136;  | True | False |
|  6137 | ៹ | OtherNumber        | &#6137;  | True | False |
|  6160 | ᠐ | DecimalDigitNumber | &#6160;  | True | True  |
|  6161 | ᠑ | DecimalDigitNumber | &#6161;  | True | True  |
|  6162 | ᠒ | DecimalDigitNumber | &#6162;  | True | True  |
|  6163 | ᠓ | DecimalDigitNumber | &#6163;  | True | True  |
|  6164 | ᠔ | DecimalDigitNumber | &#6164;  | True | True  |
|  6165 | ᠕ | DecimalDigitNumber | &#6165;  | True | True  |
|  6166 | ᠖ | DecimalDigitNumber | &#6166;  | True | True  |
|  6167 | ᠗ | DecimalDigitNumber | &#6167;  | True | True  |
|  6168 | ᠘ | DecimalDigitNumber | &#6168;  | True | True  |
|  6169 | ᠙ | DecimalDigitNumber | &#6169;  | True | True  |
|  6470 | ᥆ | DecimalDigitNumber | &#6470;  | True | True  |
|  6471 | ᥇ | DecimalDigitNumber | &#6471;  | True | True  |
|  6472 | ᥈ | DecimalDigitNumber | &#6472;  | True | True  |
|  6473 | ᥉ | DecimalDigitNumber | &#6473;  | True | True  |
|  6474 | ᥊ | DecimalDigitNumber | &#6474;  | True | True  |
|  6475 | ᥋ | DecimalDigitNumber | &#6475;  | True | True  |
|  6476 | ᥌ | DecimalDigitNumber | &#6476;  | True | True  |
|  6477 | ᥍ | DecimalDigitNumber | &#6477;  | True | True  |
|  6478 | ᥎ | DecimalDigitNumber | &#6478;  | True | True  |
|  6479 | ᥏ | DecimalDigitNumber | &#6479;  | True | True  |
|  6608 | ᧐ | DecimalDigitNumber | &#6608;  | True | True  |
|  6609 | ᧑ | DecimalDigitNumber | &#6609;  | True | True  |
|  6610 | ᧒ | DecimalDigitNumber | &#6610;  | True | True  |
|  6611 | ᧓ | DecimalDigitNumber | &#6611;  | True | True  |
|  6612 | ᧔ | DecimalDigitNumber | &#6612;  | True | True  |
|  6613 | ᧕ | DecimalDigitNumber | &#6613;  | True | True  |
|  6614 | ᧖ | DecimalDigitNumber | &#6614;  | True | True  |
|  6615 | ᧗ | DecimalDigitNumber | &#6615;  | True | True  |
|  6616 | ᧘ | DecimalDigitNumber | &#6616;  | True | True  |
|  6617 | ᧙ | DecimalDigitNumber | &#6617;  | True | True  |
|  6618 | ᧚ | OtherNumber        | &#6618;  | True | False |
|  6784 | ᪀ | DecimalDigitNumber | &#6784;  | True | True  |
|  6785 | ᪁ | DecimalDigitNumber | &#6785;  | True | True  |
|  6786 | ᪂ | DecimalDigitNumber | &#6786;  | True | True  |
|  6787 | ᪃ | DecimalDigitNumber | &#6787;  | True | True  |
|  6788 | ᪄ | DecimalDigitNumber | &#6788;  | True | True  |
|  6789 | ᪅ | DecimalDigitNumber | &#6789;  | True | True  |
|  6790 | ᪆ | DecimalDigitNumber | &#6790;  | True | True  |
|  6791 | ᪇ | DecimalDigitNumber | &#6791;  | True | True  |
|  6792 | ᪈ | DecimalDigitNumber | &#6792;  | True | True  |
|  6793 | ᪉ | DecimalDigitNumber | &#6793;  | True | True  |
|  6800 | ᪐ | DecimalDigitNumber | &#6800;  | True | True  |
|  6801 | ᪑ | DecimalDigitNumber | &#6801;  | True | True  |
|  6802 | ᪒ | DecimalDigitNumber | &#6802;  | True | True  |
|  6803 | ᪓ | DecimalDigitNumber | &#6803;  | True | True  |
|  6804 | ᪔ | DecimalDigitNumber | &#6804;  | True | True  |
|  6805 | ᪕ | DecimalDigitNumber | &#6805;  | True | True  |
|  6806 | ᪖ | DecimalDigitNumber | &#6806;  | True | True  |
|  6807 | ᪗ | DecimalDigitNumber | &#6807;  | True | True  |
|  6808 | ᪘ | DecimalDigitNumber | &#6808;  | True | True  |
|  6809 | ᪙ | DecimalDigitNumber | &#6809;  | True | True  |
|  6992 | ᭐ | DecimalDigitNumber | &#6992;  | True | True  |
|  6993 | ᭑ | DecimalDigitNumber | &#6993;  | True | True  |
|  6994 | ᭒ | DecimalDigitNumber | &#6994;  | True | True  |
|  6995 | ᭓ | DecimalDigitNumber | &#6995;  | True | True  |
|  6996 | ᭔ | DecimalDigitNumber | &#6996;  | True | True  |
|  6997 | ᭕ | DecimalDigitNumber | &#6997;  | True | True  |
|  6998 | ᭖ | DecimalDigitNumber | &#6998;  | True | True  |
|  6999 | ᭗ | DecimalDigitNumber | &#6999;  | True | True  |
|  7000 | ᭘ | DecimalDigitNumber | &#7000;  | True | True  |
|  7001 | ᭙ | DecimalDigitNumber | &#7001;  | True | True  |
|  7088 | ᮰ | DecimalDigitNumber | &#7088;  | True | True  |
|  7089 | ᮱ | DecimalDigitNumber | &#7089;  | True | True  |
|  7090 | ᮲ | DecimalDigitNumber | &#7090;  | True | True  |
|  7091 | ᮳ | DecimalDigitNumber | &#7091;  | True | True  |
|  7092 | ᮴ | DecimalDigitNumber | &#7092;  | True | True  |
|  7093 | ᮵ | DecimalDigitNumber | &#7093;  | True | True  |
|  7094 | ᮶ | DecimalDigitNumber | &#7094;  | True | True  |
|  7095 | ᮷ | DecimalDigitNumber | &#7095;  | True | True  |
|  7096 | ᮸ | DecimalDigitNumber | &#7096;  | True | True  |
|  7097 | ᮹ | DecimalDigitNumber | &#7097;  | True | True  |
|  7232 | ᱀ | DecimalDigitNumber | &#7232;  | True | True  |
|  7233 | ᱁ | DecimalDigitNumber | &#7233;  | True | True  |
|  7234 | ᱂ | DecimalDigitNumber | &#7234;  | True | True  |
|  7235 | ᱃ | DecimalDigitNumber | &#7235;  | True | True  |
|  7236 | ᱄ | DecimalDigitNumber | &#7236;  | True | True  |
|  7237 | ᱅ | DecimalDigitNumber | &#7237;  | True | True  |
|  7238 | ᱆ | DecimalDigitNumber | &#7238;  | True | True  |
|  7239 | ᱇ | DecimalDigitNumber | &#7239;  | True | True  |
|  8304 | ⁰ | OtherNumber        | &#8304;  | True | False |
|  8308 | ⁴ | OtherNumber        | &#8308;  | True | False |
|  8309 | ⁵ | OtherNumber        | &#8309;  | True | False |
|  8310 | ⁶ | OtherNumber        | &#8310;  | True | False |
|  8311 | ⁷ | OtherNumber        | &#8311;  | True | False |
|  8312 | ⁸ | OtherNumber        | &#8312;  | True | False |
|  8313 | ⁹ | OtherNumber        | &#8313;  | True | False |
|  8320 | ₀ | OtherNumber        | &#8320;  | True | False |
|  8321 | ₁ | OtherNumber        | &#8321;  | True | False |
|  8322 | ₂ | OtherNumber        | &#8322;  | True | False |
|  8323 | ₃ | OtherNumber        | &#8323;  | True | False |
|  8324 | ₄ | OtherNumber        | &#8324;  | True | False |
|  8325 | ₅ | OtherNumber        | &#8325;  | True | False |
|  8326 | ₆ | OtherNumber        | &#8326;  | True | False |
|  8327 | ₇ | OtherNumber        | &#8327;  | True | False |
|  8328 | ₈ | OtherNumber        | &#8328;  | True | False |
|  8329 | ₉ | OtherNumber        | &#8329;  | True | False |
|  8528 | ⅐ | OtherNumber        | &#8528;  | True | False |
|  8529 | ⅑ | OtherNumber        | &#8529;  | True | False |
|  8530 | ⅒ | OtherNumber        | &#8530;  | True | False |
|  8531 | ⅓ | OtherNumber        | &#8531;  | True | False |
|  8532 | ⅔ | OtherNumber        | &#8532;  | True | False |
|  8533 | ⅕ | OtherNumber        | &#8533;  | True | False |
|  8534 | ⅖ | OtherNumber        | &#8534;  | True | False |
|  8535 | ⅗ | OtherNumber        | &#8535;  | True | False |
|  8536 | ⅘ | OtherNumber        | &#8536;  | True | False |
|  8537 | ⅙ | OtherNumber        | &#8537;  | True | False |
|  8538 | ⅚ | OtherNumber        | &#8538;  | True | False |
|  8539 | ⅛ | OtherNumber        | &#8539;  | True | False |
|  8540 | ⅜ | OtherNumber        | &#8540;  | True | False |
|  8541 | ⅝ | OtherNumber        | &#8541;  | True | False |
|  8542 | ⅞ | OtherNumber        | &#8542;  | True | False |
|  8543 | ⅟ | OtherNumber        | &#8543;  | True | False |
|  8544 | Ⅰ | LetterNumber       | &#8544;  | True | False |
|  8545 | Ⅱ | LetterNumber       | &#8545;  | True | False |
|  8546 | Ⅲ | LetterNumber       | &#8546;  | True | False |
|  8547 | Ⅳ | LetterNumber       | &#8547;  | True | False |
|  8548 | Ⅴ | LetterNumber       | &#8548;  | True | False |
|  8549 | Ⅵ | LetterNumber       | &#8549;  | True | False |
|  8550 | Ⅶ | LetterNumber       | &#8550;  | True | False |
|  8551 | Ⅷ | LetterNumber       | &#8551;  | True | False |
|  8552 | Ⅸ | LetterNumber       | &#8552;  | True | False |
|  8553 | Ⅹ | LetterNumber       | &#8553;  | True | False |
|  8554 | Ⅺ | LetterNumber       | &#8554;  | True | False |
|  8555 | Ⅻ | LetterNumber       | &#8555;  | True | False |
|  8556 | Ⅼ | LetterNumber       | &#8556;  | True | False |
|  8557 | Ⅽ | LetterNumber       | &#8557;  | True | False |
|  8558 | Ⅾ | LetterNumber       | &#8558;  | True | False |
|  8559 | Ⅿ | LetterNumber       | &#8559;  | True | False |
|  8560 | ⅰ | LetterNumber       | &#8560;  | True | False |
|  8561 | ⅱ | LetterNumber       | &#8561;  | True | False |
|  8562 | ⅲ | LetterNumber       | &#8562;  | True | False |
|  8563 | ⅳ | LetterNumber       | &#8563;  | True | False |
|  8564 | ⅴ | LetterNumber       | &#8564;  | True | False |
|  8565 | ⅵ | LetterNumber       | &#8565;  | True | False |
|  8566 | ⅶ | LetterNumber       | &#8566;  | True | False |
|  8567 | ⅷ | LetterNumber       | &#8567;  | True | False |
|  8568 | ⅸ | LetterNumber       | &#8568;  | True | False |
|  8569 | ⅹ | LetterNumber       | &#8569;  | True | False |
|  8570 | ⅺ | LetterNumber       | &#8570;  | True | False |
|  8571 | ⅻ | LetterNumber       | &#8571;  | True | False |
|  8572 | ⅼ | LetterNumber       | &#8572;  | True | False |
|  8573 | ⅽ | LetterNumber       | &#8573;  | True | False |
|  8574 | ⅾ | LetterNumber       | &#8574;  | True | False |
|  8575 | ⅿ | LetterNumber       | &#8575;  | True | False |
|  8576 | ↀ | LetterNumber       | &#8576;  | True | False |
|  8577 | ↁ | LetterNumber       | &#8577;  | True | False |
|  8578 | ↂ | LetterNumber       | &#8578;  | True | False |
|  8581 | ↅ | LetterNumber       | &#8581;  | True | False |
+-------+---+--------------------+----------+------+-------+

【讨论】:

真正完整的答案!

以上是关于C# 中 Char.IsDigit() 和 Char.IsNumber() 的区别的主要内容,如果未能解决你的问题,请参考以下文章

C#如何将double转为char

Char.IsDigit与Char.IsNumber的区别

c#中的文本框里怎么判断输入的内容是啥类型

使用javascript制作加法计算器中检测用户输入的数值是否为正整数

C#实用小知识:string和判断null

文本过滤