Hi all,

I was wondering something. Is it a good idea to declare a StringBuilder object as a class level variable?

For instance, I have a variable called CLogText that is declared at the class level. I use this object to build error messages each time an exception is thrown, and write it to a log.

I know I can keep appending text to it, but I want each exception entry to be separate.

The way I was thinking of doing it would be to keep the class level declaration, but just clear the buffer each time I write an exception like so:
Code:
ClogText.Replace(ClogText.ToString, " ")
I'd really like to avoid declaring a new StringBuilder in each procedure. Just trying to make as many reuseable objects as I can.

Mods, I didn't know exactly what forum this fit into. I just put it in here because it's a web application.