C# String Chars
Description
String Chars
gets the Char object at a specified position
in the current String object.
Syntax
String.Chars
has the following syntax.
public char this[
int index
] { get; }
Parameters
String.Chars
has the following parameters.
index
- A position in the current string.
Example
In C#, the Chars property is an indexer.
//from ww w. j a va 2s . com
using System;
public class MainClass{
public static void Main(String[] argv){
string str1 = "Test";
for (int ctr = 0; ctr <= str1.Length - 1; ctr++ ){
Console.Write("{0} ", str1[ctr]);
}
}
}
The code above generates the following result.