3

I am working on some pretty complex code that is writing to a memorystream using an XmlTextwriter. Is there a way in Visual Studio debug to see the content of the memorystream/XmlTextwriter as I am stepping through code.

Robert
  • 1,129
  • 2
  • 12
  • 23

1 Answers1

8

It's easy to get it from the MemoryStream:

Encoding.UTF8.GetString(stream.ToArray())

(That's assuming you've told it to use UTF-8; use Encoding.Unicode or whatever's appropriate if necessary.)

It doesn't make as much sense to ask the XmlTextWriter - it's just writing data, and probably doesn't know or care what it's already written. You may want to flush it, mind you.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Thanks Jon. You always help me out. BTW how long have you been programming? – Robert Sep 16 '11 at 12:49
  • 2
    @Robert: It depends on exactly what you mean... I wrote my first programs on a Spectrum when I was about 8, 27 years ago :) – Jon Skeet Sep 16 '11 at 12:51