Hi..
Ques : What is the C# equivalent of C++ catch (…). which was a catch all statement for any possible exception?
What is the C# equivalent of C++ catch
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 7, 2012, 6:11 AM EST
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);
}