Brett said:
Using the example in my initial post, say I add two events to the
deletgate t0. Can I use a foreach loop to get at items stored in the t0
delegate type?
IF you have access to the delegate object itself you can foreach through
Delegate.GetInvocationList which is an array. Arrays implement IList which
inherits from IEnumerable via ICollection.
Now, it isn't necessary that I implement IEnurmerable to use a for each
loop? I ask that question because every time I have used a for each loop,
I haven't implemented IEnumerable. However, from the docs:
[IEnumerable must be implemented to support the ForEach semantics of
Microsoft Visual Basic. COM classes that allow enumerators also implement
this interface.]
The object you are enumerating on must implement IEnumerable (the one in the
"in" part of your foreach).
If the above is true, then t0 is a collection because IEnumerable is in
the System.Collections namespace.
Sorry, wrong. DictionaryEntry, Comparer, and IHashCodeProvider are all in
the System.Collections namespace and are not collections. Being in the
namespace does not imply that they ARE collections, merely that they are
related to collections in some way. You're confusing location with identity.
Just to reinforce my point, t0.GetInvocationList returns an array which IS a
collection (since it implements ICollection), but Array resides in the
System namespace.