Saturday, 7 June 2008

How do I create a StringWriter with encoding in C#.NET?

Simple, yet effective.

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

public class StringWriterWithEncoding : StringWriter
{
public StringWriterWithEncoding( StringBuilder builder, Encoding encoding )
: base( builder )
{
_encoding = encoding;
}

Encoding _encoding;

public override Encoding Encoding
{
get { return _encoding; }
}
}

No comments: