StringBuilder.Clear Method is used to remove all the characters from the current StringBuilder instance.
public System.Text.StringBuilder Clear ();
It returns an StringBuilder object whose length will be 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 String is: GeeksforGeeks Total characters -- 13 The String is: Total characters -- 0 The String is: This is C# Tutorials. Total characters -- 22
- StringBuilder in C#
- C# | String vs StringBuilder
- How to create the StringBuilder in C#
- How to find the length of the StringBuilder in C#
- How to find the MaxCapacity of a StringBuilder in C#
- StringBuilder.EnsureCapacity() Method in C#
- StringBuilder.ToString Method in C#
- StringBuilder.CopyTo Method in C#
- How to find the Capacity of a StringBuilder in C#
- C# | Creating StringBuilder having specified capacity
- StringBuilder.Chars Property in C#
- C# | Check if two StringBuilder objects are Equal
- C# | Remove() Method
- C# | Remove entry with specified key from the StringDictionary
- C# | Remove all the strings from the StringCollection
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.