Convert StringWriter to string[]
<p>I had a requirement to create a <code>TextWriter</code> to populate some data. I used the <code>StringWriter</code> as a TextWriter and the business logic works fine. </p>

<p>I have a technical requirement that cannot be changed because it may break all the clients. I need to  an array of strings <code>string[]</code> from the <code>TextWriter</code> separated by line.</p>

<p>I tried with this but didn't work:</p>

<pre><code>using System;
using System.IO;
using System.Text;

namespace TextWriterToArrayOfStringsDemo
{
    internal static class Program
    {
        private static void Main()
        {
            var stringBuilder = new StringBuilder();
            using (TextWriter writer = new StringWriter(stringBuilder))
            {
                writer.Write("A");
                writer.WriteLine();
                writer.Write("B");
            }

            string fullString = stringBuilder.ToString();
            string replaced = fullString.Replace('\n', '\r');
            string[] arrayOfString = replaced.Split('\r');

            // Returns false but should return true
            Console.WriteLine(arrayOfString.Length == 2);
        }
    }
}
</code></pre>

<p>Any idea or suggestion?</p>
