Functions.CheckInstanceOf 方法 |
命名空间: XSharp.RT
FUNCTION CheckInstanceOf( oObject AS Object, symClassName AS STRING ) AS LOGIC
public static bool CheckInstanceOf( Object oObject, string symClassName )
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{"小明", "总裁"} 13 y := Male{"小张", "副总"} 14 ? CheckInstanceOf(x, #Person) // TRUE 15 ? CheckInstanceOf(x, #Male) // FALSE 16 ? CheckInstanceOf(y, #Person) // TRUE 17 ? CheckInstanceOf(y, #Male) // TRUE