Char.IsDigit Method

Definition

指示 Unicode 字符是否属于十进制数字类别。Indicates whether a Unicode character is categorized as a decimal digit.

Overloads

IsDigit(Char)

指示指定的 Unicode 字符是否属于十进制数字类别。Indicates whether the specified Unicode character is categorized as a decimal digit.

IsDigit(String, Int32)

指示指定字符串中位于指定位置处的字符是否属于十进制数字类别。Indicates whether the character at the specified position in a specified string is categorized as a decimal digit.

Examples

下面的代码示例演示 IsDigitThe following code example demonstrates IsDigit.

using namespace System;
int main()
{
   char ch = '8';
   Console::WriteLine( Char::IsDigit( ch ) ); // Output: "True"
   Console::WriteLine( Char::IsDigit(  "sample string", 7 ) ); // Output: "False"
}
using System;

public class IsDigitSample {
    public static void Main() {
        char ch = '8';

        Console.WriteLine(Char.IsDigit(ch));					// Output: "True"
        Console.WriteLine(Char.IsDigit("sample string", 7));	// Output: "False"
    }
}
Module IsDigitSample

    Sub Main()

        Dim ch8 As Char
        ch8 = "8"c

        Console.WriteLine(Char.IsDigit(ch8))                    ' Output: "True"
        Console.WriteLine(Char.IsDigit("sample string", 6))     ' Output: "False"

    End Sub

End Module

Remarks

有效数字是 UnicodeCategory.DecimalDigitNumber 类别的成员。Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

IsDigit(Char)

指示指定的 Unicode 字符是否属于十进制数字类别。Indicates whether the specified Unicode character is categorized as a decimal digit.

public:
 static bool IsDigit(char c);
public static bool IsDigit (char c);
static member IsDigit : char -> bool
Public Shared Function IsDigit (c As Char) As Boolean

Parameters

c
Char

要计算的 Unicode 字符。The Unicode character to evaluate.

Returns

Boolean

如果 true 是十进制数,则为 c;否则为 falsetrue if c is a decimal digit; otherwise, false.

Remarks

此方法确定 Char 是否为10基数数字。This method determines whether a Char is a radix-10 digit. 这与 IsNumber的对比,后者确定 Char 是否为任何数值 Unicode 类别。This contrasts with IsNumber, which determines whether a Char is of any numeric Unicode category. 数字包含字符,如分数、下标、上标、罗马数字、货币分子、encircled 数和特定于脚本的数字。Numbers include characters such as fractions, subscripts, superscripts, Roman numerals, currency numerators, encircled numbers, and script-specific digits.

有效数字是 UnicodeCategory.DecimalDigitNumber 类别的成员。Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

See also

IsDigit(String, Int32)

指示指定字符串中位于指定位置处的字符是否属于十进制数字类别。Indicates whether the character at the specified position in a specified string is categorized as a decimal digit.

public:
 static bool IsDigit(System::String ^ s, int index);
public static bool IsDigit (string s, int index);
static member IsDigit : string * int -> bool
Public Shared Function IsDigit (s As String, index As Integer) As Boolean

Parameters

s
String

一个字符串。A string.

index
Int32

s 中要计算的字符的位置。The position of the character to evaluate in s.

Returns

Boolean

如果 true 中位于 index 的字符是一个十进制数,则为 s;否则为 falsetrue if the character at position index in s is a decimal digit; otherwise, false.

Exceptions

snulls is null.

index 小于零或大于 s 中最后一个位置。index is less than zero or greater than the last position in s.

Remarks

此方法确定 Char 是否为10基数数字。This method determines whether a Char is a radix-10 digit. 这与 IsNumber的对比,后者确定 Char 是否为任何数值 Unicode 类别。This contrasts with IsNumber, which determines whether a Char is of any numeric Unicode category. 数字包含字符,如分数、下标、上标、罗马数字、货币分子、encircled 数和特定于脚本的数字。Numbers include characters such as fractions, subscripts, superscripts, Roman numerals, currency numerators, encircled numbers, and script-specific digits.

字符串中的字符位置从零开始索引。Character positions in a string are indexed starting from zero.

有效数字是 UnicodeCategory.DecimalDigitNumber 类别的成员。Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

See also

Applies to