Method call parameter values

  • Thread starter Thread starter Michal Januszczyk
  • Start date Start date
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
 
You can try

using System.Reflection;

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

mfg GP
 
Back
Top