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 difference between throw and throw ex inside a catch? 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? 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

When should you use using or await using?

Intermediate

Answer

For IDisposable/IAsyncDisposable resources — they call Dispose/DisposeAsync deterministically at the end of scope, even on exceptions, replacing manual try/finally.
await using var conn = new SqlConnection(cs);
await conn.OpenAsync();
Real-world example Guaranteeing a stream or connection is released promptly rather than waiting for GC.
Previous question What does the finally block guarantee, and when is it commonly used? Next question What are exception filters (when) and why use them?
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.