Retrieves or assigns the length of the current StringBuilder.
[Visual Basic] Public Property Length As Integer [C#] public int Length {get; set;} [C++] public: __property int get_Length(); public: __property void set_Length(int); [JScript] public function get Length() : int; public function set Length(int);
The length of the current instance.
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | The specified length for set is less than 0. |
ArgumentOutOfRangeException | The specified length for set is greater than MaxCapacity. |
If the length specified is less than the current instance, the StringBuilder is truncated. If the length is set to a value greater than the current length, the capacity is adjusted to be the same as the specified length. However, the length specified cannot be greater than MaxCapacity.
StringBuilder Class | StringBuilder Members | System.Text Namespace