Strings.GetChar Method

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

Returns a Char value representing the character from the specified index in the supplied string.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

Syntax

'Declaration
Public Shared Function GetChar ( _
    str As String, _
    Index As Integer _
) As Char
public static char GetChar(
    string str,
    int Index
)

Parameters

  • Index
    Type: System.Int32
    Required. Integer expression. The (1-based) index of the character in str to be returned.

Return Value

Type: System.Char
Returns a Char value representing the character from the specified index in the supplied string.

Remarks

If Index is less than 1 or greater than the index of the last character in str, an ArgumentException is thrown.

Examples

This example shows how to use the GetChar function to return a character from a specified index in a String.

Dim TestString As String = "ABCDE"
Dim TestChar As Char
' Returns "D"
TestChar = GetChar(TestString, 4)

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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