Export (0) Print
Expand All

Char.IsLetter Method (String, Int32)

.NET Framework 1.1

Indicates whether the character at the specified position in a specified string is categorized as an alphabetic character.

[Visual Basic]
Overloads Public Shared Function IsLetter( _
   ByVal s As String, _
   ByVal index As Integer _
) As Boolean
[C#]
public static bool IsLetter(
 string s,
 int index
);
[C++]
public: static bool IsLetter(
 String* s,
 int index
);
[JScript]
public static function IsLetter(
   s : String,
 index : int
) : Boolean;

Parameters

s
A string.
index
The character position in s.

Return Value

true if the character at position index in s is an alphabetic character; otherwise, false.

Exceptions

Exception Type Condition
ArgumentNullException s is a null reference (Nothing in Visual Basic).
ArgumentOutOfRangeException index is less than zero or greater than the last position in s.

Remarks

Character positions in a string are indexed starting from zero.

Valid letters are members of the following categories in UnicodeCategory: UppercaseLetter, LowercaseLetter, TitlecaseLetter, ModifierLetter, and OtherLetter.

Example

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

[Visual Basic] 
Imports System

Module IsLetterSample

    Sub Main()

        Dim ch8 As Char
        ch8 = "8"c

        Console.WriteLine(Char.IsLetter(ch8))                   ' Output: "False"
        Console.WriteLine(Char.IsLetter("sample string", 5))    ' Output: "True"

    End Sub

End Module

[C#] 
using System;

public class IsLetterSample {
    public static void Main() {
        char ch = '8';

        Console.WriteLine(Char.IsLetter(ch));                    // False
        Console.WriteLine(Char.IsLetter("sample string", 7));    // True
    }
}

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

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

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

[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, Common Language Infrastructure (CLI) Standard

See Also

Char Structure | Char Members | System Namespace | Char.IsLetter Overload List | Boolean

Show:
© 2014 Microsoft