Lire en anglais Modifier

Partager via


Char.IsDigit Method

Definition

Indicates whether a Unicode character is categorized as a decimal digit.

Overloads

IsDigit(Char)

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

The following code example demonstrates IsDigit.

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"
    }
}

Remarks

Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

IsDigit(Char)

Source:
Char.cs
Source:
Char.cs
Source:
Char.cs

Indicates whether the specified Unicode character is categorized as a decimal digit.

public static bool IsDigit (char c);

Parameters

c
Char

The Unicode character to evaluate.

Returns

true if c is a decimal digit; otherwise, false.

Remarks

This method determines whether a Char is a radix-10 digit. 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.

Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

See also

Applies to

.NET 9 et autres versions
Produit Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

IsDigit(String, Int32)

Source:
Char.cs
Source:
Char.cs
Source:
Char.cs

Indicates whether the character at the specified position in a specified string is categorized as a decimal digit.

public static bool IsDigit (string s, int index);

Parameters

s
String

A string.

index
Int32

The position of the character to evaluate in s.

Returns

true if the character at position index in s is a decimal digit; otherwise, false.

Exceptions

index is less than zero or greater than the last position in s.

Remarks

This method determines whether a Char is a radix-10 digit. 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.

Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

See also

Applies to

.NET 9 et autres versions
Produit Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0