checking types

B

Brian Henry

I have this statement in C# i want to convert to vb.net but cant find a
direct conversion, how do i do it?

foreach(type iface in t.GetInterfaces())
{
if (iface.Equals(typeof(IMyInterface)))
{
/// do something
}
}

in vb.net i did

for each iface as type in t.GetInterfaces()
If iface.Equals(typeof(IMyInterface)) Then
''' do something
End If
next

which of course says IMyInterface is a type and connot be used as an
expression and 'is' is expected for the equals line... how do convert this?
i just want to check to see if an assembly implements a specific interface..
thanks!
 
B

Brian Henry

i think this is the correct way? if there is a better one please let me know
if iface.Equals(GetType(IMyInterface)) Then
 
G

Guest

This might work:

foreach f as iface in t.GetInterfaces
if typeof f is IMyInterface
' dosomething
next
 

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