Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to use StringBuilder in C#?
With StringBuilder, you can expand the number of characters in the string. String cannot be changed once it is created, but StringBuildercan be expanded. It does not create a new object in the memory.
Initialize StringBuilder.
StringBuilder str = new StringBuilder();
Let us see an example to learn how to work with StringBuilder in C#.
Example
using System;
using System.Text;
public class Program {
public static void Main() {
StringBuilder str = new StringBuilder("Web World!!",30);
str.Replace("World", "Arena");
Console.WriteLine(str);
}
}
Output
Web Arena!!
Above the Replace() method of StringBuilder is used to to replace a string in C#.
Advertisements
