Hello
Here is some code:
string str = "System.String";
object[] parameters = new object[] { 'h', 5 };
object o = System.Activator.CreateInstance( Type.GetType( str ),
parameters );
System.Diagnostics.Debug.WriteLine( o.GetType().ToString() + " = " +
o.ToString() );
Activator.CreateInstance() can create an instance of an object of specified
type. If your object has parameterless constructor, then you can skip
parameters specification.
The above sample will create a String object, using the next constructor
CString(char c, int count).
--
With best regards,
Andrew
http://www.codeproject.com/script/pr...asp?id=1181072
"John Hughes" <jh******@msn.com> wrote in message
news:eN**************@TK2MSFTNGP15.phx.gbl...
Hi,
Is it possible to create an object from a stored (database,xml or
variable) name?
For instance I have 2 class names stored in my database. Depending on the
application settings I want to create an object based on the class name
that I store in the database.
Any ideas how to do this?