Working with StringBuilder Class in C#
In this article we will discuss about what is StringBuilder Class in C#.
The StringBuilder Class is used for mutable string .i.e. the string which can be changed. Creating a new object every time we change the string sounds reasonable if our program deals with strings having moderate length. But if the program extensively performs text processing, then this may affect the performance of the program as there may be a number of unreferenced objects on the heap waiting to be collected by the garbage collector. Hence .NET provided other another class named StringBuilder to cope with this problem.
Although StringBuilder does not provide as much functionality as the String class, it certainly provides methods for the most common operations. To be able to use StringBuilder Class we must import classes of System.Text namespace.
static void Main(string args)
StringBuilder sb = new StringBuilder("punet");
Console.WriteLine("The new string is: "+sb);
You may also want to read these related articles.
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here