Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:14:12+00:00 2026-06-07T07:14:12+00:00

I have read somewhere on this site or CodeProject that good rule is if

  • 0

I have read somewhere on this site or CodeProject that good rule is if some class has implemented IDisposable interface than and only than you should use using keyword because using keyword translated into MSIL is try/finally block something like this:

try
{
   //some logic 
}
finally
{
   if (obj != null)
      {
         obj.Dispose();
      }
}

but while watching tutorials for Entity Framework, I came across something like this:

using(SampleBEntities db = new SampleBEntities()){//some logic here} 

and SampleBEntities inherits from ObjectContext and in the MSDN lib ObjectContext does not implement the IDisposable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:14:14+00:00Added an answer on June 7, 2026 at 7:14 am

    Yes it does implement IDisposable interface.

    public class ObjectContext : IDisposable
    

    Check MSDN

    It has methods Dispose() which comes from implementing IDisposable interface.

    If it did not implement as you stated leave alone running, it won’t even compile.

    using statements

    Using defines a scope, outside of which an object or objects will be disposed.

    C#, through the .NET Framework common language runtime (CLR), automatically releases the memory used to store objects that are no longer required. The release of memory is non-deterministic; memory is released whenever the CLR decides to perform garbage collection.

    The using statement allows us to specify when objects that use resources should release them. The object provided to the using statement must implement the IDisposable interface. This interface provides the Dispose method, which should release the object’s resources.

    A using statement can be exited either when the end of the using statement is reached or if an exception is thrown and control leaves the statement block before the end of the statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I read somewhere that some modules only have object oriented interfaces (
I have read somewhere that CreateGraphics() will do this steps for us : BeginPaint
I have read somewhere that if class A is loaded by ClassLoaderA then all
I have read somewhere that Silverlight is subset of WPF , then why triggers
To create a daemon I have read somewhere that in order to close all
I am sure I have read this somewhere, Can anyone tell me what the
I have read somewhere that hyperthreading can make 32-bit int (on a 32-bit processor)
I read (somewhere else on this site) you can't reload (or inject javascript) onto
I have read somewhere (can't remeber where and how) that NHibernate 3 allows the
I have read somewhere that we can restrict the scope of global variable to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.