C# StringWriter StringWriter(StringBuilder)

Description

StringWriter StringWriter(StringBuilder) Initializes a new instance of the StringWriter class that writes to the specified StringBuilder.

Syntax

StringWriter.StringWriter(StringBuilder) has the following syntax.


public StringWriter(
  StringBuilder sb
)

Parameters

StringWriter.StringWriter(StringBuilder) has the following parameters.

  • sb - The StringBuilder to write to.

Example

The following code example demonstrates using the StringBuilder class to modify the underlying string in a closed StringWriter.


using System;//from   w ww.j ava2 s .c  om
using System.IO;
using System.Text;

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

        strWriter.Close();
        Console.WriteLine(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