The
is <Class> operator is used to find out whether the object used is an object of the class (or an object of one of its derived classes).
Syntax
<Result> = <Object> is <Class>
<Result>: Boolean
- True if the object used is an object of the class (or an object of one of its derived classes),
- False otherwise.
<Object>: Class object
Name of the object whose test must be run. This object can be a dynamic object or not.
<Class>: Class
Class name. The object can belong (or not) to this class.
Remarks
Four classes are used in this example:
- BaseClass1
- BaseClass2
- DerivedClase that derives from BaseClass1
- DoubleDerivedClase that derives from BaseClass1 and from BaseClass2
The following code is used to check whether the object belongs to the different classes.
Result1 is boolean
Object1 is dynamic BaseClass1 object
Object1 = new BaseClass1
Result1 = Object1 is BaseClass1 // Result1 contains "True"
Result1 = Object1 is BaseClass2 // Result1 contains "False"
Result1 = Object1 is DerivedClass // Result1 contains "False"
Result1 = Object1 is DoubleDerivedClass // Result1 contains "False"
Object1 = new DerivedClass
Result1 = Object1 is BaseClass1 // Result1 contains "True"
Result1 = Object1 is BaseClass2 // Result1 contains "False"
Result1 = Object1 is DerivedClass // Result1 contains "True"
Result1 = Object1 is DoubleDerivedClass // Result1 contains "False"
Object1 = new DoubleDerivedClass
Result1 = Object1 is BaseClass1 // Result1 contains "True"
Result1 = Object1 is BaseClass2 // Result1 contains "True"
Result1 = Object1 is DerivedClass // Result1 contains "False"
Result1 = Object1 is DoubleDerivedClass // Result1 contains "True"
Remark
The
Class property is used to get the actual type of the class instance used by a variable of type object, dynamic object or variant.