Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 07, 2012 02:15 AM by Decker Dong - MSFT
Jun 05, 2012 04:26 PM|LINK
I'm not sure if anyone knows where this information might be found (or if it even can be) But I am looking for a deconstruction of the "DataTable" and "DataView" objects.
What I mean is I woudl like to know how the DataTabel object is put together (with DataRow and DataColumn objects) and also how the DataView object is put together. ideally woudl be sample code of how the objects are contructed.
Jun 07, 2012 02:15 AM|LINK
As far as I see，I'm afraid you cannot find such a method in the DataTable——generally speaking，I think in .net framework there are two kinds of disposible way——
1）Implement IDispose interface，this will be Dispose all the managed things。
2）Just use a Deconstrcutor，to destroy all the unmanaged things。
But DataTable doesn't seem to find either of them——Look at its defination in the reflector：
public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializeNotification, ISupportInitialize, ISerializable, IXmlSerializable
So is the DataView——
public class DataView : MarshalByValueComponent, IBindingListView, IBindingList, IList, ICollection, IEnumerable, ITypedList, ISupportInitializeNotification, ISupportInitialize
Really？！The answer is——No！Because either DataTable or DataView has inherits from MarshalByValueComponent，and this class has implemented IDispose——
protected virtual void Dispose(bool disposing)
if ((this.site != null) && (this.site.Container != null))
if (this.events != null)
EventHandler handler = (EventHandler) this.events[EventDisposed];
if (handler != null)
Considerint it that the deconstructor will be executed at a random time，so when set a "false" inside as as parameter，you can see that all the managed things won't be gabaged again.