This example demostrate you that how to use StringWriter class in C#. The given program trying to write string using StringWriter class.
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