更新时间:2022-06-10 08:32:51
是
运营商检查如果一个对象可以转换为特定类型。
The is
operator checks if an object can be cast to a specific type.
例如:
if (someObject is StringBuilder) ...
为
运营商尝试将对象强制转换为特定类型,并返回null如果失败。
The as
operator attempts to cast an object to a specific type, and returns null if it fails.
例如:
StringBuilder b = someObject as StringBuilder;
if (b != null) ...
还有相关的:
Also related:
借助转换运算符试图将对象转换为特定类型,并抛出exeption如果失败。
The cast operator attempts to cast an object to a specific type, and throws an exeption if it fails.
例如:
StringBuilder b = (StringBuilder)someObject.