Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

StringBuilder.Chars Property

Gets or sets the character at the specified character position in this instance.

[C#] In C#, this property is the indexer for the StringBuilder class.

[Visual Basic]
Public Default Property Chars( _
   ByVal index As Integer _
) As Char
public char this[
 int index
] {get; set;}
public: __property __wchar_t get_Chars(
 int index
public: __property void set_Chars(
 int index,
returnValue = StringBuilderObject.Chars(index);
StringBuilderObject.Chars(index) = returnValue;
returnValue = StringBuilderObject(index);
StringBuilderObject(index) = returnValue;

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed property whose type is Object and whose index type is String.

Arguments [JScript]

The position of the character.

Parameters [Visual Basic, C#, C++]

The position of the character.

Property Value

The Unicode character at position index.


Exception Type Condition
ArgumentOutOfRangeException index is outside the bounds of this instance while setting a character.
IndexOutOfRangeException index is outside the bounds of this instance while getting a character.


The index parameter is the position of a character within the StringBuilder. The first character in the string is at index 0. The length of a string is the number of characters it contains. The last accessible character of a StringBuilder instance is at index Length- 1.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

StringBuilder Class | StringBuilder Members | System.Text Namespace | String

© 2017 Microsoft