在C#中,"is"关键字必须后跟一个类吗?

New*_*ang 3 c# class

在Actionscript中,您可以让变量保存对类类型的引用,然后将类的实例与变量进行比较is.例:

var a:Foo = new Foo();
var type:Class = Foo;

if(a is type){  //this is true
  //do something
}
Run Code Online (Sandbox Code Playgroud)

你能用C#做类似的事吗?或者"is"关键字是否必须后跟一个类?

new*_*cct 10

如果要针对变量类型进行测试,请参阅.NET框架中的Type.IsInstanceOfType方法