StringReader Class and StringWriter Class

Overview

  • Used to read and write in-memory strings.
  • StringWriter uses a StringBuilder behind the scenes.

Examples

Read and Write Strings

StringWriter a = new StringWriter();
a.Write("Hello World!");
a.Write(a.NewLine);
a.Write("I span two lines!");
 
StringReader r = new StringReader(a.ToString());
 
while (r.Peek() != -1)
{
    Console.WriteLine(r.ReadLine());
}
 
learning/exam70-536/stringreader.txt · Last modified: 2008/08/27 13:41 by david
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki