StringBuilder::Clear Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Removes all characters from the current StringBuilder instance.

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

public:
StringBuilder^ Clear()

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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top
Show: