Is there a TextWriter interface to the System.Diagnostics.Debug class?

Posted by John Källén on Stack Overflow See other posts from Stack Overflow or by John Källén
Published on 2010-05-06T08:54:06Z Indexed on 2010/05/06 8:58 UTC
Read the original article Hit count: 150

Filed under:
|

I'm often frustrated by the System.Diagnostics.Debug.Write/WriteLine methods. I would like to use the Write/WriteLine methods familiar from the TextWriter class, so I often write

Debug.WriteLine("# entries {0} for connection {1}", countOfEntries, connection);

which causes a compiler error. I end up writing

Debug.WriteLine(string.Format("# entries {0} for connection {1}", 
    countOfEntries, connection));

which is really awkward.

Does the CLR have a class deriving from TextWriter that "wraps" System.Debug, or should I roll my own?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#