IsInstanceOf Function |
Namespace: XSharp.RT
FUNCTION IsInstanceOf( oObject AS Object, symClassName AS STRING ) AS LOGIC
public static bool IsInstanceOf( Object oObject, string symClassName )
1CLASS Employee 2 EXPORT name, age 3CONSTRUCTOR(tName, tAge) 4 name := tName 5 age := tAge 6END CLASS 7CLASS Programmer INHERIT Employee 8END CLASS 9CLASS Assembler INHERIT Programmer 10END CLASS 11FUNCTION CheckArgument() 12 LOCAL x, y AS OBJECT 13 x := Employee{"John", "25"} 14 y := Assembler{"Bill", "30"} 15 ? IsInstanceOf(x, #Employee) // TRUE 16 ? IsInstanceOf(x, #Programmer) // FALSE 17 ? IsInstanceOf(x, #Assembler) // FALSE 18 ? IsInstanceOf(y, #Employee) // TRUE 19 ? IsInstanceOf(y, #Programmer) // TRUE 20 ? IsInstanceOf(y, #Assembler) // TRUE