C# StringBuilder ToString()
Description
StringBuilder ToString()
Converts the value of this
instance to a String.
Syntax
StringBuilder.ToString()
has the following syntax.
public override string ToString()
Returns
StringBuilder.ToString()
method returns A string whose value is the same as this instance.
Example
using System;//from w ww .j a va2s . c o m
using System.Text;
class Sample
{
public static void Main()
{
string str = "The quick br!wn d#g jumps #ver the lazy cat.";
StringBuilder sb = new StringBuilder(str);
sb.Replace("dog", "fox", 15, 20); // Some "dog" -> "fox"
// Display the number of characters in the StringBuilder and its string.
Console.WriteLine("{0} chars: {1}", sb.Length, sb.ToString());
}
}
The code above generates the following result.