Char.IsDigit Char.IsDigit Char.IsDigit Char.IsDigit Method

定義

指示 Unicode 字元是否分類為十進位數字。Indicates whether a Unicode character is categorized as a decimal digit.

多載

IsDigit(Char) IsDigit(Char) IsDigit(Char) IsDigit(Char)

指示指定的 Unicode 字元是否分類為十進位數字。Indicates whether the specified Unicode character is categorized as a decimal digit.

IsDigit(String, Int32) IsDigit(String, Int32) IsDigit(String, Int32) IsDigit(String, Int32)

指示指定的字串中指定位置處的字元是否分類為十進位數字。Indicates whether the character at the specified position in a specified string is categorized as a decimal digit.

備註

有效的數位是UnicodeCategory.DecimalDigitNumber類別目錄的成員。Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

IsDigit(Char) IsDigit(Char) IsDigit(Char) 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

參數

c
Char Char Char Char

要評估的 Unicode 字元。The Unicode character to evaluate.

傳回

true 是十進位數字時為 c,否則為 falsetrue if c is a decimal digit; otherwise, false.

範例

下列程式碼範例將IsDigit示範。The 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

備註

這個方法Char會判斷是否為基數10位數。This method determines whether a Char is a radix-10 digit. Char會與IsNumber進行比較,以判斷是否為任何數值 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.

另請參閱

IsDigit(String, Int32) IsDigit(String, Int32) IsDigit(String, Int32) 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

參數

s
String String String String

字串。A string.

index
Int32 Int32 Int32 Int32

要評估的字元在 s 中的位置。The position of the character to evaluate in s.

傳回

true 中位於 index 的字元是十進位數字時為 s,否則為 falsetrue if the character at position index in s is a decimal digit; otherwise, false.

例外狀況

index 小於零或大於 s 中的最後一個位置。index is less than zero or greater than the last position in s.

範例

下列程式碼範例將IsDigit示範。The 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

備註

這個方法Char會判斷是否為基數10位數。This method determines whether a Char is a radix-10 digit. Char會與IsNumber進行比較,以判斷是否為任何數值 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.

另請參閱

適用於