C-SHARP - 4.8 StringBuilder
Hello everyone and welcome to this new video. In this video, we will discuss the concept of StringBuilder. But before getting to the heart of the matter. I will clear up a point with you. You know that when we have a string of character string, this is actually an object of class string. Ok, then you know that a string is immutable i.e. it is not possible to modify this string. Each time we use one of the methods belonging to the string class, we create a new object in memory, which requires a new allocation of space for this new object. Either the memory overload can quickly be present if repeated modifications are made, each modification will cost a place in memory. And to remedy this, we have the Stringbuilder to avoid creating a new object with each modification. For example, the StringBuilder class improves performance when concatenating a large number of strings in a loop. But unlike the String class, it is not optimized for search. So, it doesn't give you access to methods like the Indexof method, or the LastIndenxof method. You know all of these string search operations now from the previous video. On the other hand, it provides a number of useful methods for manipulating strings like Append() to add something to the end of a string, Insert() to add something to the index, Remove() to remove something of the string Replace() to replace a character or a string and as well as clear to erase everything. Now let's go to Visual Studio and see the Stringbuilder together.