14.9.9 The is operator
来源:互联网 发布:淘宝卖茶叶图片大全 编辑:程序博客网 时间:2024/06/05 14:30
The is operator is used to dynamically check if the run-time type of an
object is compatible with a given
type. The result of the operation e is T, where e is an expression and T is
a type, is a boolean value
indicating whether e can successfully be converted to type T by a reference
conversion, a boxing conversion,
or an unboxing conversion. The operation is evaluated as follows:
?If the compile-time type of e is the same as T, or if an implicit
reference conversion (?3.1.4) or boxing
conversion (?3.1.5) exists from the compile-time type of e to T:
If e is of a reference type, the result of the operation is equivalent to
evaluating e != null.
If e is of a value type, the result of the operation is true.
?Otherwise, if an explicit reference conversion (?3.2.3) or unboxing
conversion (?3.2.4) exists from
the compile-time type of e to T, a dynamic type check is performed:
If the value of e is null, the result is false.
Otherwise, let R be the run-time type of the instance referenced by e. If R
and T are the same type, if R is a
reference type and an implicit reference conversion from R to T exists, or
if R is a value type and T is an
interface type that is implemented by R, the result is true.
Otherwise, the result is false.
?Otherwise, no reference or boxing conversion of e to type T is possible,
and the result of the operation is
false.
The is operator only considers reference conversions, boxing conversions,
and unboxing conversions. Other
conversions, such as user defined conversions, are not considered by the is
operator.
object is compatible with a given
type. The result of the operation e is T, where e is an expression and T is
a type, is a boolean value
indicating whether e can successfully be converted to type T by a reference
conversion, a boxing conversion,
or an unboxing conversion. The operation is evaluated as follows:
?If the compile-time type of e is the same as T, or if an implicit
reference conversion (?3.1.4) or boxing
conversion (?3.1.5) exists from the compile-time type of e to T:
If e is of a reference type, the result of the operation is equivalent to
evaluating e != null.
If e is of a value type, the result of the operation is true.
?Otherwise, if an explicit reference conversion (?3.2.3) or unboxing
conversion (?3.2.4) exists from
the compile-time type of e to T, a dynamic type check is performed:
If the value of e is null, the result is false.
Otherwise, let R be the run-time type of the instance referenced by e. If R
and T are the same type, if R is a
reference type and an implicit reference conversion from R to T exists, or
if R is a value type and T is an
interface type that is implemented by R, the result is true.
Otherwise, the result is false.
?Otherwise, no reference or boxing conversion of e to type T is possible,
and the result of the operation is
false.
The is operator only considers reference conversions, boxing conversions,
and unboxing conversions. Other
conversions, such as user defined conversions, are not considered by the is
operator.
- 14.9.9 The is operator
- What is the name of the “-->” operator?(Stackoverflow)
- 14.9.10 The as operator
- What is the !! (not not) operator in JavaScript?
- 9.Which statement is true regarding the INTERSECT operator?
- 152.Which statement is true regarding the UNION operator?
- The operator == is undefined for the argument type(s) int, null
- The operator || is undefined for the argument type(s) int, int
- 'operator <<' is ambiguous
- What is operator overloading
- 'operator <<' is ambiguous
- 'init(start:end:)' is deprecated: it will be removed in Swift 3. Use the '..<' operator
- 1Z0-051 9.Which statement is true regarding the INTERSECT operator?
- overload the operator
- Explaining the PeopleCode @ operator
- qmake "The *= operator"
- perl the special operator
- The sizeof Operator
- 14.9.4 Boolean equality operators
- 14.9.5 Enumeration comparison operators
- 14.9.6 Reference type equality operators
- 14.9.7 String equality operators
- 14.9.8 Delegate equality operators
- 14.9.9 The is operator
- 14.9.10 The as operator
- 14.10 Logical operators
- 14.11 Conditional logical operators
- 当Spring遇到Ruby
- ASP源码现阶段最好的保护方案软件特点:无需改动原网站代码,无需写成DLL。加解快速方便。加密后的密文能法解密。
- 图片等比例截取
- [免费]新增日期控件的下载
- tomcat中文路径名问题的解决