DataTable inherited from the MarshalByValueComponent class, which implements the IDisposable interface (see below), C # allows you to call public methods of the base class for instances of derived classes.
public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializeNotification, ISupportInitialize, ISerializable, IXmlSerializable public class MarshalByValueComponent : IComponent, IDisposable, IServiceProvider
Your code block will be presented under the hood, as shown below, so it ensures that the Dispose () method is called:
{ DataTable dt = Admin_User_Functions.Admin_KitItems_GetItems() try { // .. code inside using statement } finally { if (dt != null) ((IDisposable)dt).Dispose(); } }
See MSDN for details: Using Statement
source share