class object create with using in c# -
create class mustdispose.cs
public class mustdispose { public mustdispose() { } }
in.aspx page
protected void page_load(object sender, eventargs e) { using (mustdispose obj = new mustdispose) { // utilize object } }
errorr
destructors , object.finalize cannot called directly. consider calling idisposable.dispose if available.
you class has impplement idisposable
, in oder used within using
statement.
example:
public class mustdispose : idisposable { public mustdispose() { } //implement dispose public void dispose() { .... } }
reading using:
provides convenient syntax ensures right utilize of idisposable objects.
c# class
No comments:
Post a Comment