Collection Objects

D

Dufus

I want a way of checking an object to see that it either implements the
IEnumerable or ICollection Interface. I could use something like this: (in
VB)
If Not obj.GetInterface "IEnumerable" is nothing Then
........

But what happens when the object is a custom collection that inherits from
another collection object that implements these interfaces.
 
M

Matt Berther

Hello Dufus,

In C#, you can use the 'is' keyword.

if (obj is IEnumerable)

in VB:

If TypeOf obj Is IEnumerable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top