I want to supply users with a GetInfoTable() method that returns some
information that will not change during the lifetime of the object it is
called on. I want something like:
class MyClass
{
private DataTable _info;
public DataTable GetInfoTable()
{
if( _info == null ) {
_info = new DataTable();
// build the table up
}
return _info;
}
}
Since the user receives a reference, I don't want any accidental calls to
Clear() or Reset() or user invoked Dispose() (via using() directive, etc).
Obviously, it should delete the data when garbage collected - i.e.
Dispose( false ).
// user code
using( DataTable dt = myClass.GetInfoTable() ) {
dt.Clear(); // does nothing
dt.Reset(); // does nothing
// user can't add rows
} // not really disposed
Philippe
P.S. Does DataTable.Reset() go back to the state after EndInit() or
EndLoad() or does it completely clean out the DataTable ?