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?
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.
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...).
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.
Try the following
if TypeOf x Is IFoo Then ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With