Create StringWriter from StringBuilder : StreamWriter : File Directory Stream C# Examples


C# Examples » File Directory Stream » StreamWriter »

 

Create StringWriter from StringBuilder









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

class  MainClass
{
    public  static  void  Main()  
    {
        StringBuilder  sb  =  new  StringBuilder();

        StringWriter  sw  =  new  StringWriter(sb);

        sw.Write("This  is  a  test  of  the  StringWriter  class");
        sw.Close();

        StringReader  sr  =  new  StringReader(sb.ToString());

        string  EntireString;
    
        EntireString  =  sr.ReadToEnd();
        Console.WriteLine(EntireString);

        sr.Close();
    }
}
    
   
  
   



Output

This is a test of the StringWriter class


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» StreamWriter