From the course: C#: Applied Data Structures

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

StringBuilder

StringBuilder

- [Instructor] Manipulating string content is probably one of the most common operations that many developers have to contend with. .Net provides a great data structure class for working with strings called the String Builder. One of the key advantages of the string builder is that it is much more efficient at making multiple changes to a string than it is to use regular string functions. And that's because the string builder allocates an internal buffer for working with the string and expands the buffer space only when it's needed. So let's try exercising some of the string builder features. So I'll open the code here and string builder lives in the system text module, so I'm including that. Let's begin by creating a new string builder with an initial capacity of 50 characters and an initial string. And these are both optional parameters. So I'll create a string builder, I'll call it sb. So I'll make a new string builder…

Contents