Skip to main content
deleted 33 characters in body
Source Link
abatishchev
  • 100.7k
  • 88
  • 305
  • 443

That is the best method. Other wise loss the StringBuilder and use something like following:

        using (MemoryStream ms = new MemoryStream())  
{
            using (StreamWriter sw = new StreamWriter(ms, Encoding.Unicode)) {
        {
        sw.WriteLine("dirty world.");
            }
            //do somthing with ms
        }

That is the best method. Other wise loss the StringBuilder and use something like following

        using (MemoryStream ms = new MemoryStream()) {
            using (StreamWriter sw = new StreamWriter(ms, Encoding.Unicode)) {
                sw.WriteLine("dirty world.");
            }
            //do somthing with ms
        }

That is the best method. Other wise loss the StringBuilder and use something like following:

using (MemoryStream ms = new MemoryStream()) 
{
    using (StreamWriter sw = new StreamWriter(ms, Encoding.Unicode))
    {
        sw.WriteLine("dirty world.");
    }
    //do somthing with ms
}
Source Link
particle
  • 3.4k
  • 4
  • 30
  • 41

That is the best method. Other wise loss the StringBuilder and use something like following

        using (MemoryStream ms = new MemoryStream()) {
            using (StreamWriter sw = new StreamWriter(ms, Encoding.Unicode)) {
                sw.WriteLine("dirty world.");
            }
            //do somthing with ms
        }