is
运算符在C#中做了什么?
答案 0 :(得分:7)
“is”运算符接受2个操作数并返回一个布尔值,表示第一个操作数被强制转换为第二个操作数的能力。例如:
if(object1 is ClassA) //returns true if object1 is derived from ClassA or can be cast into ClassA.
答案 1 :(得分:4)
如果是,表达式的计算结果为true 提供的表达式为非null, 并且可以将提供的对象强制转换为 提供的类型没有导致 抛出异常。
来源:http://msdn.microsoft.com/en-us/library/scekt9xw(v=vs.80).aspx