Initializes a new instance of the StringWriter class that writes to the specified StringBuilder. : StringWriter « File Stream « C# / C Sharp






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

 


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

class StrWriter
{
    static void Main()
    {
        StringBuilder strBuilder = 
            new StringBuilder("file path characters are: ");
        StringWriter strWriter = new StringWriter(strBuilder);

        strWriter.Write(
            Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);

        strWriter.Close();

        strBuilder.Insert(0, "Invalid ");
        Console.WriteLine(strWriter.ToString());
    }
}

   
  








Related examples in the same category

1.Use StringWriter to write string
2.The hex dump program.
3.StringWriter implements a TextWriter for writing information to a string. The information is stored in an underlying StringBuilder.
4.Initializes a new instance of the StringWriter class with the specified format control.
5.Initializes a new instance of the StringWriter class.