MCQ on Using Statement for C # Certification Practice

Here is a question from the book: C # Programming Exam 70-483 Answer: c.

An object that implements IDisposable is passed to your class as an argument. Should I wrap the element in a using statement?

and. Yes, otherwise a memory leak may occur.
B. No, you must call Close on the object.
C. No, you must use a try / finally expression and call Dispose yourself.
D. No, the caller must use a using statement.

I'm a little confused as to why c. In the question, by argument, do they mean the object is being passed as an argument type to the class?

+3


source to share


1 answer


Regardless of how or why or when an argument is passed, you should never destroy an instance that you did not create. (d) is correct, (c) does not matter.



+2


source







All Articles