Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the VB.NET equivalent of the C# "is" keyword?

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?

like image 270
Tahbaza Avatar asked Jul 02 '10 16:07

Tahbaza


People also ask

Is VB.NET the same as C#?

Though C# and VB.NET are syntactically very different, that is where the differences mostly end. Microsoft developed both of these languages to be part of the same . NET Framework development platform. They are both developed, managed, and supported by the same language development team at Microsoft.

Is VB.NET similar to C++?

You are right, C++ and VB are two completely different languages and have quite a few fundamental differences (managed vs. unmanaged being a major one that comes to mind...).

What is VB and C?

Summary: 1. C is a programming language for general purpose computers; VB is an event driven programming language that was designed to make computer programming easier for programming beginners.


1 Answers

Try the following

if TypeOf x Is IFoo Then    ... 
like image 127
JaredPar Avatar answered Sep 17 '22 13:09

JaredPar