May 2010
Intermediate to advanced
1272 pages
61h 18m
English
Although not often utilized, you can take advantage of StringReader and StringWriter for manipulating strings. The following example generates a new StringBuilder and associates it to a new StringWriter. Then it retrieves the list of filenames in the C:\ directory and puts each string into the writer. You notice that, because of the association between the two objects, changes are reflected to the StringBuilder. Try this:

To read strings you can use the StringReader object, whose constructor requires a string to be read. To continue with the example, we can read the previously created StringBuilder line by line:
You ...
Read now
Unlock full access