1 2 3 z z z z z
This is a C# Program to illustrate stringbuilder.
This C# Program Illustrates StringBuilder.
Here ToString method is used on the StringBuilder type. This method is used to convert a StringBuilder’s character buffer into an actual string reference.
Here is source code of the C# Program to Illustrate StringBuilder. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Illustrate StringBuilder */ using System; using System.Text; class Program { static void Main() { StringBuilder bd = new StringBuilder(); bd.Append("1 "); bd.Append("2 "); bd.Append("3 "); for (int i = 0; i < 5; i++) { bd.Append("z "); } string result = bd.ToString(); Console.WriteLine(result); Console.ReadLine(); } }
This C# program is used to illustrate StringBuilder. The Append() method is used to append a copy of the specified string to this instance. Using for loop append the value of ‘z’ character value to the remaining values in for loop.
ToString() method is used on the StringBuilder type. This method is used to convert a StringBuilder’s character buffer into an actual string reference.
1 2 3 z z z z z