C# StringBuilder Chars
Description
StringBuilder Chars
Gets or sets the character at the
specified character position in this instance.
Syntax
StringBuilder.Chars
has the following syntax.
public char this[
int index
] { get; set; }
Parameters
StringBuilder.Chars
has the following parameters.
index
- The position of the character.
Example
using System;/*from ww w . j av a 2 s .c o m*/
using System.Text;
public class Example
{
public static void Main()
{
StringBuilder sb = new StringBuilder("This is a test from java2s.com.");
for (int ctr = 0; ctr < sb.Length; ctr++) {
char ch = sb[ctr];
Console.WriteLine(ch);
}
}
}
The code above generates the following result.