1. Home
  2. Computer Science MCQs
  3. Dot NET
  4. In C#, which statement ensures an IDisposable object is…

Added 2 Nov 2026

In C#, which statement ensures an IDisposable object is disposed automatically at the end of a block?

  1. lock
  2. checked
  3. using Correct answer
  4. fixed

Correct answer

C. using

15 views

MCQSEXAM

Explanation

The using statement calls Dispose() automatically, even if an exception occurs, which is ideal for files and database connections. lock is for thread synchronisation.

Reference

Asked in: NTS, PPSC, Technical Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Dot NET MCQs

Practise all Dot NET MCQs

Similar MCQs