Hi..
Ques : What is the C# equivalent of C++ catch (…). which was a catch all statement for any possible exception?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Feb 7, 2012, 11:11 AM
try
{
// code
}
catch
{
// catches any exception
}
If you need to access the Exception object, you can also do this:
try
{
// code
}
catch (Exception ex)
{
// catches any exception derived from System.Exception
Console.WriteLine(ex.Message);
}