Outputting contents of a variable

M

Mehmet Koseoglu

Hello all,
I need help about writing the contents of parameters of a method to a
file when an exception occurs. For example, I have method as the
following:

public void Method(Object objParameter, string str)
{
try
{
//Some code
}
catch(Exception e)
{
//At this point in the code, I want to write contents of the
parameters objParameter and str
}
}

The parameters can be of any type, so there can be some other objects
inside them. Basically, I want an output similar to the watch window
in debug mode, or call stack window displaying parameters' values.
A simple way is to write contents of the objects explicitly, but I
need a general code block so that I can copy it to any other method
without modifying it.
Do you know a way to implement his? Or can you point out some
references so that I can learn how to do it?
Thanks in advance..

Mehmet Koseoglu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top