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

Definition

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

Overloads

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

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.

Remarks

Valid digits are members of the UnicodeCategory.DecimalDigitNumber category.

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

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 Char Char Char

The Unicode character to evaluate.

Returns

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

Examples

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

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

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
Parameters
s
String String String String

A string.

index
Int32 Int32 Int32 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

Examples

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

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