Question discussion

In C#, the using statement is used to ensure that

2301Medium DSSSB TGT Computer Science 0 replies 1 views
0

In C#, the using statement is used to ensure that

  • Aan object is created on the stack and not on the heap
  • Ba namespace is imported into the file
  • Can object implementing IDisposable is disposed as soon as the block is exited
  • Dan exception thrown inside the block is ignored
Correct answer: C

Explanation

using (var x = ...) { } calls x.Dispose() automatically when control leaves the block, even if an exception occurs.

Discussion 0

Nobody has replied yet. Start the discussion!