Export (0) Print
Expand All

Char.IsDigit Method (Char)

.NET Framework 1.1

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

[Visual Basic]
Overloads Public Shared Function IsDigit( _
   ByVal c As Char _
) As Boolean
[C#]
public static bool IsDigit(
 char c
);
[C++]
public: static bool IsDigit(
 __wchar_t c
);
[JScript]
public static function IsDigit(
   c : Char
) : Boolean;

Parameters

c
A Unicode character.

Return Value

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

Remarks

This method determines if a Char is a radix-10 digit. This contrasts with IsNumber which determines if a Char is of any numeric Unicode category.

Valid digits are members of the following category in UnicodeCategory: DecimalDigitNumber.

Example

[Visual Basic, C#, C++] The following sample demonstrates IsDigit.

[Visual Basic] 
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

[C#] 
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"
    }
}

[C++] 
#using <mscorlib.dll>
using namespace System;

int main() {
   char ch = '8';

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Char Structure | Char Members | System Namespace | Char.IsDigit Overload List | Boolean | IsNumber

Show:
© 2015 Microsoft