什么是C#的VB.NET等效项“是”?关键词?

问题描述:

我需要检查给定对象是否实现了接口。在C#中,我只是说:

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

if (x is IFoo) { }

正在使用 TryCast(),然后检查 Nothing 最佳方法?

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

尝试以下操作

if TypeOf x Is IFoo Then 
  ...