> I have a query about the garbage collection
>
> If i an array of an object of size, say 1000, and the object
> implements Idisposable, first of all how should i call dispose method
> on an object array.
You'd call Dispose on each element of the array, if it's not null.
> To better understand the query i am providing a
> snippet here which will create a collection of objects.
[quoted text clipped - 14 lines]
> for them, so there is no option looping through the Collection to free
> the unmanaged resources.
Why do you think there isn't a way of looping through the whole
collection? For each element of the collection, just check whether it's
non-null and implements IDisposable, and call Dispose if so.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
saurabhgarg2k@gmail.com - 04 Apr 2005 20:25 GMT
Sorry Jon,
i mistakenly write there is no option looping, of course looping is the
option but wat my query is that is this the only option, cant i dispose
the whole clooection and the underlying objects without looping.
Thanks and Regards
Saurabh Garg
Jon wrote:
> > I have a query about the garbage collection
> >
[quoted text clipped - 31 lines]
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
Jon Skeet [C# MVP] - 04 Apr 2005 20:33 GMT
> i mistakenly write there is no option looping, of course looping is the
> option but wat my query is that is this the only option, cant i dispose
> the whole clooection and the underlying objects without looping.
No. You can easily write a helper method to do that though, and call
that from various places.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Sherif ElMetainy - 10 Apr 2005 23:45 GMT
The framework collections do not implement IDisposable.
You can implement you own collection class that implements IDisposable
interface. In the dispose method loop throw all objects and dispose those
which are not null and implements IDisposable.
Please note that disposing the whole collection is not a good idea if the
objects in the collections are referenced by another objects.
Best regards,
Sherif
> Sorry Jon,
> i mistakenly write there is no option looping, of course looping is the
[quoted text clipped - 46 lines]
>> http://www.pobox.com/~skeet
>> If replying to the group, please do not mail me too