![]() |
| | #1 |
| Registered User Join Date: May 2006
Posts: 1,579
| Types that own disposable fields should be disposable For this best practices rule, http://msdn.microsoft.com/en-us/ms182172.aspx What are the benefits of following this rule even if I am not wrapping an unmanaged resource, like FileStream in the sample in the page. I think it is fine if the class does not implement IDisposable, since FileStream could be disposed (to release the native file handle) since it has its own Dispose method. Any ideas? thanks in advance, George |
| George2 is offline |
| | #2 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| It doesn't matter if the class you wrap has any handles internally. For all you know, the class you wrap needs to be disposed. If your class is disposed, the members of your class should be disposed, too. And if the class you wrap is disposable, you should not hide this with your wrapper class.
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| My Program gives a load of errors on comile, can some1 help explain them to me please | MadnessRed | C Programming | 6 | 08-23-2008 01:16 PM |
| The Interactive Animation - my first released C program | ulillillia | General Discussions | 48 | 05-10-2007 02:25 AM |
| Dikumud | maxorator | C++ Programming | 1 | 10-01-2005 06:39 AM |
| i am not able to figure ot the starting point of this | youngashish | C++ Programming | 7 | 10-07-2004 02:41 AM |