views:

107

answers:

4

I need to check if a given object implements an interface. In C# I would simply say:

if (x is IFoo) { }

Is using a TryCast() and then checking for Nothing the best way?

+3  A: 

Try the following

if TypeOf x Is IFoo Then 
  ...
JaredPar
thanks / the TypeOf keyword is what I was missing
Tahbaza
+3  A: 

Like this:

If TypeOf x Is IFoo Then
SLaks
+2  A: 

Use following online web solution for same and all other code conversion visa-versa.

http://bit.ly/7P949

Thanks

Vivek Navadia
A: 

http://www.developerfusion.com/tools/convert/csharp-to-vb/ is also a great conversion tool.

Logan Young