MCQs > IT & Programming > C# > Which of the following code snippets for catch shows a better way of handling an exception? 1. catch (Exception exc) {    throw exc; } 2. catch (Exception exc) {     throw; }

C# MCQs

Which of the following code snippets for catch shows a better way of handling an exception?

1.

catch (Exception exc)

{

    throw exc;

}

2.

catch (Exception exc)

{

    throw;

}

Answer

Correct Answer: 2 is better as it maintains the call stack.

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it