charAt

Summary

Extracts the character from a given position in the string.

Usage

public char charAt(int index)

Returns

The character at the given position. If the position is invalid, an empty string will be returned.

Parameters

index

The position in the string to get the character.

Description

Extracts the character from a given position in the string. If the position is invalid (e.g. the provided position is a negative number or goes beyond the end of the string), an empty string will be returned.

Examples

Basic Usage
1
2
3
4
5
6
import System;
 
string abc = "abc";
Console.log(abc.charAt(0)); // "a"
Console.log(abc.charAt(1)); // "b"
Console.log(abc.charAt(2)); // "c"

Share

HTML | BBCode | Direct Link