Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Clear Method

StringBuilder.Clear Method

Removes all characters from the current StringBuilder instance.

Namespace:  System.Text
Assembly:  mscorlib (in mscorlib.dll)

member Clear : unit -> StringBuilder

Return Value

Type: System.Text.StringBuilder
An object whose Length is 0 (zero).

Clear is a convenience method that is equivalent to setting the Length property of the current instance to 0 (zero).

Calling the Clear method does not modify the current instance's Capacity or MaxCapacity property.

The following example instantiates a StringBuilder object with a string, calls the Clear method, and then appends a new string.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft