C# StringWriter GetStringBuilder

Description

StringWriter GetStringBuilder Returns the underlying StringBuilder.

Syntax

StringWriter.GetStringBuilder has the following syntax.


public virtual StringBuilder GetStringBuilder()

Returns

StringWriter.GetStringBuilder method returns The underlying StringBuilder.

Example


/*from   w ww  .j av  a 2 s .  c  o m*/

using System;
using System.Globalization;
using System.IO;
using System.Text;

class StrWriter
{
    static void Main()
    {
        StringBuilder strBuilder = new StringBuilder("from java2s.com ");

        StringWriter strWriter = new StringWriter(strBuilder, new CultureInfo("ar-DZ"));

        strWriter.Write(DateTime.Now);

        strWriter.GetStringBuilder().Insert(0, "Invalid ");

        Console.WriteLine(DateTime.Now.ToString(), strWriter.ToString());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter