Quantcast
Channel: User Michael Paulukonis - Stack Overflow
Viewing all articles
Browse latest Browse all 44

Answer by Michael Paulukonis for Clear all content in XmlTextWriter and StringWriter

$
0
0

You'd think there would be an intuitive way to do this, but....

A solution I found suggests the following:

// make a StringWriter, and fill it with junkStringWriter sw = new StringWriter();sw.Write("Don't want to see this");// and HERE IS THE MAGICStringBuilder sb = sw.GetStringBuilder();sb.Remove(0, sb.Length);// your StringWriter is now empty!

This worked for me (in the same situation as you -- using an XmlTextWriter that dumps to the StringWriter).

Perhaps somebody has an intuitive answer for why nothing like this is built-in.


Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>