Question
· Nov 9, 2018

Dynamically Creating Class (Reflection in C#)

I need to dynamically create a class based on a parameter passed into a class method.  Basically the method takes in a string that contains the name of the class I need to create a new instance of. 

I need something along these lines. 

ClassMethod someMethod(className As %String)
{
	set classObject = ##class(className).%New()

...
}

Trying to do this right results in a class not found error because it seems to be treating the variable as a literal string.

Discussion (3)1
Log in or sign up to continue