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;否则为 false true if c is a decimal digit; otherwise, false.

示例

下面的代码示例演示了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"
	}
}
Imports System

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. 这与形成对比IsNumber,用于确定是否Char的任何数值的 Unicode 类别。This contrasts with IsNumber, which determines whether a Char is of any numeric Unicode category. 数字包含诸如分数、 下标、 上标、 罗马数字、 货币分子、 循环的数和特定于脚本的数字字符。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;否则为 false true 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.

示例

下面的代码示例演示了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"
	}
}
Imports System

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. 这与形成对比IsNumber,用于确定是否Char的任何数值的 Unicode 类别。This contrasts with IsNumber, which determines whether a Char is of any numeric Unicode category. 数字包含诸如分数、 下标、 上标、 罗马数字、 货币分子、 循环的数和特定于脚本的数字字符。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.

另请参阅

适用于