Information
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
[C#]
public char this[
 int index
] {get; set;}
[C++]
public: __property __wchar_t get_Chars(
 int index
);
public: __property void set_Chars(
 int index,
   __wchar_t
);
[JScript]
returnValue = StringBuilderObject.Chars(index);
StringBuilderObject.Chars(index) = returnValue;
-or-
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]

index
The position of the character.

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

index
The position of the character.

Property Value

The Unicode character at position index.

Exceptions

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.

Remarks

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.

Requirements

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

Show:
© 2014 Microsoft