Wednesday, 14 August 2013

How to deal with IDisposable?

How to deal with IDisposable?

Let say I have these 3 classes.
abstract class MyBase
{
//some base code here
}
class Foo : MyBase, IDisposable
{
//got at least a field I should dispose
}
class Bar : MyBase, IDisposable
{
//got at least a field I should dispose
}
I have a few classes like that. I got classes that own a List<base>. How
could I dispose properly of all those classes without having to test/cast
to get the proper type and then having Dispose ?

No comments:

Post a Comment