1
Vote

StreamReaderWrap casts TextReader to StreamReader

description

As the title says that is what is happening in
 
<code>
public void Initialize(TextReader textReader)
    {
        StreamReaderInstance = textReader as StreamReader;
    }
</code>
 
But TextReade does not implement stream reader (it is the other way around) so that cast will always result in "null" being set as streamreaderinstance.

comments

svrist wrote Apr 2, 2012 at 2:44 PM

This means that i cant do things like:

new StreamReaderWrap(new StringReader("something")); // null pointer exception on all methods on the wrap

This is a workaround

new StreamReaderWrap(
                new MemoryStream(
                    Encoding.UTF8
                        .GetBytes("Something")
                    )
                );

wrote Feb 14, 2013 at 7:40 PM