This documentation is archived and is not being maintained.

Char.IsLetterOrDigit Method (Char)

.NET Framework 1.1

Indicates whether the specified Unicode character is categorized as an alphabetic letter or a decimal digit.

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

Parameters

c
A Unicode character.

Return Value

true if c is an alphabetic letter or a decimal digit; otherwise, false.

Remarks

Valid alphabetic letters and decimal digits are members of the following categories in UnicodeCategory: UppercaseLetter, LowercaseLetter, TitlecaseLetter, ModifierLetter, OtherLetter, or DecimalDigitNumber.

Example

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

[Visual Basic] 
imports System

Module IsLetterOrDigitSample

    Sub Main()

        Dim str As String
        str = "newline:" + vbNewLine

        Console.WriteLine(Char.IsLetterOrDigit("8"c))       ' Output: "True"
        Console.WriteLine(Char.IsLetterOrDigit(str, 8))     ' Output: "False", because it's a NewLine

    End Sub

End Module

[C#] 
using System;

public class IsLetterOrDigitSample {
    public static void Main() {
        string str = "newline:\n";

        Console.WriteLine(Char.IsLetterOrDigit('8'));        // Output: "True"
        Console.WriteLine(Char.IsLetterOrDigit(str, 8));    // Output: "False", because it's a newline
    }
}

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

int main() {
   String* str = "newline:\n";

   Console::WriteLine(Char::IsLetterOrDigit('8'));      // Output: "True"
   Console::WriteLine(Char::IsLetterOrDigit(str, 8));   // Output: "False", because it's a newline
}

[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.IsLetterOrDigit Overload List | Boolean

Show: