Sponsored Ad

Monday, January 17, 2011

Stringwriter Class in C# – Example Code

This example demostrate you that how to use StringWriter class in C#. The given program trying to write string using StringWriter class.

StringReader and Stringwriter Class in C#

C# Source Code:

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

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder strb = new StringBuilder();
            strb.Append("StringBuilder.");
            StringWriter strw = new StringWriter(strb);
            Writetxt(strw);
            Console.WriteLine(strb);

        Console.ReadLine();
          }
        static void Writetxt(TextWriter tw)
        {
            tw.WriteLine("TextWriter.");
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates