1

I have service which does not implement IDisposable in its class. While creating object for class, I putting object creation statement in Using statement. I executed the code, it not giving any error. Can you explain why the creation object which does not implement IDisposable not throwing exception in using statement.

1
  • 4
    Your base class would have implemented IDisposable. Post the code you're talking about. Commented Sep 8, 2014 at 7:41

1 Answer 1

5

No. That is not possible.

If you use this code:

using (object o = new object())
{ }

You receive:

'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'

The easy reason you won't see it implements IDisposable is that one of its base classes implements IDisposable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.