_CreateInstance Function (String, Usual) | |
Create an object.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION _CreateInstance(
symClassName AS STRING,
InitArgList AS USUAL[]
) AS Object
public static Object _CreateInstance(
string symClassName,
Usual[] InitArgList
)
Request Example
View SourceParameters
- symClassName
- Type: String
The name of the class for which you want to create an object. - InitArgList
- Type: Usual
A comma-separated list of arguments to pass to the Init() method of symClassName (see example below).
Return Value
Type:
ObjectRemarks
CreateInstance() is the functional way to create an object of a particular class.
It is essentially the same as creating an object through an invocation of {}, but is useful in situations where a functional form is needed.
Examples
This example shows how an object is created using CreateInstance():
1CLASS Person
2 EXPORT name, sign
3CONSTRUCTOR(tName, tSign)
4 name := tName
5 sign := tSign
6END CLASS
7
8FUNCTION Start()
9 LOCAL x AS OBJECT
10
11
12 x := CreateInstance(#PERSON, "Odile", "H")
13 ? x:name
See Also