Method call parameter values

M

Michal Januszczyk

is it possible to do the following thing: ?

class MyClass
{
private int val1;
private string val2;
...
private type valM;

public void func1(arg1,arg2,...argN)
{
try{
//some operations...
}
catch(Exception ex)
{
string AllContextData;

//In this place I would like to get All values
//of argumets passed to function currently
//having been entered (in this situtaution Func1)
//Also, I want to get values (and names if
//possible)of all class members. These all values
//i want to put into AllContextData (after
//ToString()method call on each value) and pass
//outside in MyException class.

//IS IT POSSIBLE ?

throw MyException(AllContextData,ex);
}

}//func

}//class


Thanks
Michal
 
G

Günter Prossliner

You can try

using System.Reflection;

try{
...
}catch(Excetion e){
ParameterInfo[] parameters = e.TargetSite.GetParameters();
...
}

mfg GP
 

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