How can I know if the current method is within a catch block?

  • Thread starter Thread starter Lei Jiang
  • Start date Start date
L

Lei Jiang

For example :

try
{
....
}
catch(Exception e)
{
foo();
}

In foo(), how can I know if the code is within the catch block? e.g.:

void foo()
{
if (currently within a catch block) // <-- how could I do this?
{
}
else
{
}
}

Thanks!
 
Lei Jiang said:
For example :

try
{
...
}
catch(Exception e)
{
foo();
}

In foo(), how can I know if the code is within the catch block? e.g.:

void foo()
{
if (currently within a catch block) // <-- how could I do this?
{
}
else
{
}
}

You can't. Why do you want to, out of interest?
 
Thank you! I just want to know if I could detect the execution context at
runtime in .NET.
 
Back
Top