Initializes a new instance of the StringWriter class. : StringWriter « File Stream « C# / C Sharp






Initializes a new instance of the StringWriter class.

 


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

class StrWriter
{
    static void Main()
    {
        StringWriter strWriter  = new StringWriter();

        strWriter.Write("file path characters are: ");
        strWriter.Write(
            Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
        strWriter.Write('.');

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

        Console.WriteLine("The following string is {0} encoded.\n{1}", 
            strWriter.Encoding.EncodingName, 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 that writes to the specified StringBuilder.