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.Chars Property in C#
- C# | String vs StringBuilder
- How to find the Capacity of a StringBuilder in C#
- How to find the length of the StringBuilder in C#
- How to find the MaxCapacity of a StringBuilder in C#
- C# | Check if two StringBuilder objects are Equal
- StringBuilder.EnsureCapacity() Method in C#
- StringBuilder.CopyTo Method in C#
- StringBuilder.ToString Method in C#
- StringBuilder in C#
- C# | Creating StringBuilder having specified capacity
- How to create the StringBuilder in C#
- C# | Remove all elements in a collection from a HashSet
- C# | Remove all objects from the Stack
- C# | Remove all objects from the Queue
- C# | Remove all elements from the Hashtable
- C# | Remove all elements from a HashSet
- C# | Remove all elements from the SortedSet
- C# | Remove all elements from the ArrayList
- C# | Remove all elements from a SortedList
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.