Object2Array Function | |
Convert the values of an object's instance variables to an array.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax FUNCTION Object2Array(
oObject AS Object
) AS ARRAY
public static Array Object2Array(
Object oObject
)
Request Example
View SourceParameters
- oObject
- Type: Object
The object containing the instance variable to convert.
Return Value
Type:
Array
An array containing the contents of all instance variables of
oObject.
Remarks
This conversion can offer you additional flexibility in manipulating data and can allow you to utilize powerful array functions, such as AEval() and AScan().
The scope throughout the function call is SELF.
Examples
This example uses Object2Array() to store INSTANCE and EXPORT instance variables into an array.
It then prints the stored instance variables. (Note that the password is not stored in the array because it is a protected instance variable.)
1CLASS Person
2 EXPORT name
3 INSTANCE grade
4 PROTECT password
5CONSTRUCTOR(tname, tgrade, tpassword)
6 name := tname
7 grade := tgrade
8 password := tpassword
9END CLASS
10FUNCTION Start()
11 LOCAL x AS OBJECT
12 LOCAL a AS ARRAY
13 LOCAL i AS SHORT
14 x := Person{"Randal", "A", "123"}
15 a := Object2Array(x)
16
17 FOR i := 1 UPTO ALen(a)
18 QOut(a[i])
19 NEXT
20
21
See Also