CheckInstanceOf Function | |
Determine if an object is an instance of a particular class.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION CheckInstanceOf(
oObject AS Object,
symClassName AS STRING
) AS LOGIC
public static bool CheckInstanceOf(
Object oObject,
string symClassName
)
Request Example
View SourceParameters
- oObject
- Type: Object
The object to check for. - symClassName
- Type: String
The class that oObject may be an instance of.
Return Value
Type:
Logic
TRUE if
oObject is an instance of
symClassName; otherwise, an error is generated. FALSE is returned if you choose to ignore the error.
If
oObject is a NULL_OBJECT, a FALSE is returned but no error is generated.
Remarks
An instance of an inherited class is also an instance of the original (super) class. However, an instance of a super class is not an instance of any of its inherited classes.
CheckInstanceOf() is similar to IsInstanceOf(), except that it also generates an error message if the specified object is not an instance of the specified class.
Examples
These examples illustrate CheckInstanceOf() on inherited classes:
1CLASS Person
2 EXPORT name, sign
3CONSTRUCTOR(tName, tSign)
4 name := tName
5 sign := tSign
6END CLASS
7CLASS Male INHERIT Person
8 EXPORT prefers
9END CLASS
10FUNCTION CheckArgument()
11 LOCAL x, y AS OBJECT
12 x := Person{"Dude", "president"}
13 y := Male{"Charlie", "VP"}
14 ? CheckInstanceOf(x, #Person)
15 ? CheckInstanceOf(x, #Male)
16 ? CheckInstanceOf(y, #Person)
17 ? CheckInstanceOf(y, #Male)
See Also