W3Teacher
  • Explore
    Browse by field
    Artificial Intelligence Accounting & Finance Information Technology
    Show all fields
  • Interview Q&A
    • All Interview Questions
    • Beginner
    • Intermediate
    • Advanced
  • Practice
    • MCQs
    • Quizzes
    • Mock Interviews
  • About
  • Sign in
  • Get Started
  1. Home
  2. C#
  3. Exception Handling
  4. Question
All 16 Exception Handling questions
More in Exception Handling
What is the purpose of the finally block? How does a try/catch block work in C#, and what happens if no matching catch clause exists? What does the finally block guarantee, and when is it commonly used? When should you use using or await using? What are exception filters (when) and why use them? How do custom exception classes work in C#, and what's the recommended convention for creating one? What is exception filtering using the 'when' clause, and what advantage does it offer over catching and manually re-throwing? Why does 'throw;' (bare throw) preserve the original stack trace, while 'throw ex;' does not? When should you create custom exceptions vs use built-in ones? What is the recommended strategy for exceptions in a layered/enterprise app?
Advertisement
C# › Exception Handling

What is the difference between throw and throw ex inside a catch?

Beginner

Answer

throw re-throws preserving the original stack trace; throw ex resets the stack trace to the current line, losing where the error really happened.
catch (Exception ex) { Log(ex); throw; }      // good
catch (Exception ex) { throw ex; }             // loses stack trace
Real-world example Preserving the original stack trace is essential for diagnosing production errors.
Next question What is the purpose of the finally block?
All 16 Exception Handling questions
W3Teacher

Learn technologies. Ace technical interviews.


    Learn
    • Technologies
    • Tutorials
    • Interview Questions
    • MCQs
    Practice
    • Quizzes
    • Mock Interviews
    • Bookmarks
    • Dashboard
    Get the latest questions & tips

    Fresh interview questions and practice tips, straight to your inbox.

    Company
    • About
    • Contact us
    • Privacy Policy
    • Terms & Conditions

    © 2026 W3Teacher. All rights reserved.