Char.IsLetter Method (String, Int32)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Indicates whether the character at the specified position in a specified string is categorized as a Unicode letter.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared Function IsLetter ( _
    s As String, _
    index As Integer _
) As Boolean
public static bool IsLetter(
    string s,
    int index
)

Parameters

  • index
    Type: System.Int32
    The position of the character to evaluate in s.

Return Value

Type: System.Boolean
true if the character at position index in s is a letter; otherwise, false.

Exceptions

Exception Condition
ArgumentNullException

s is nulla 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.

This method determines whether the character at a specified index position in a string is a member of any category of Unicode letter. Unicode letters include the following:

  • Uppercase letters, such as U+0041 (LATIN CAPITAL LETTER A) through U+005A (LATIN CAPITAL LETTER Z), or U+0400 (CYRILLIC CAPITAL LETTER IE WITH GRAVE) through U+042F (CYRILLIC CAPITAL LETTER YA). These characters are members of the UnicodeCategory.UppercaseLetter category.

  • Lowercase letters, such as U+0061 (LATIN SMALL LETTER A) through U+007A (LATIN SMALL LETTER Z), or U+03AC (GREEK SMALL LETTER ALPHA WITH TONOS) through U+03CE (GREEK SMALL LETTER OMEGA WITH TONOS). These characters are members of the UnicodeCategory.LowercaseLetter category.

  • Title case letters, such as U+01C5 (LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON) or U+1FFC (GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI). These characters are members of the UnicodeCategory.TitlecaseLetter category.

  • Modifiers, such as U+02B0 (MODIFIER LETTER SMALL H) through U+02C1 (MODIFIER LETTER REVERSED GLOTTAL STOP), or U+1D2C (MODIFIER LETTER CAPITAL A) through U+1D61 (MODIFIER LETTER SMALL CHI). These characters are members of the UnicodeCategory.ModifierLetter category.

  • Other letters, such as U+05D0 (HEBREW LETTER ALEF) through U+05EA (HEBREW LETTER TAV), U+0621 (ARABIC LETTER HAMZA) through U+063A (ARABIC LETTER GHAIN), or U+4E00 (<CJK Ideograph, First>) through U+9FC3 (<CJK Ideograph, Last>). These characters are members of the UnicodeCategory.OtherLetter category.

Examples

The following example demonstrates IsLetter.


Module Example

   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

      Dim ch8 As Char
      ch8 = "8"c

      outputBlock.Text &= Char.IsLetter(ch8) & vbCrLf                   ' Output: "False"
      outputBlock.Text += String.Format(Char.IsLetter("sample string", 5)) & vbCrLf    ' Output: "True"

   End Sub

End Module
using System;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      char ch = '8';

      outputBlock.Text += Char.IsLetter(ch).ToString() + "\n";          
      outputBlock.Text += Char.IsLetter("sample string", 7).ToString() + "\n";  
   }
   // The example displays the following output:
   //    False
   //    True
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.