Object.factory

Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor.

class Object
static
factory
(
string classname
)

Return Value

Type: Object

null if failed

Examples

1 module foo.bar;
2 
3 class C
4 {
5    this() { x = 10; }
6    int x;
7 }
8 
9 void main()
10 {
11    auto c = cast(C)Object.factory("foo.bar.C");
12    assert(c !is null && c.x == 10);
13 }
Suggestion Box / Bug Report