Need help in object creation

  • Thread starter Thread starter sunil
  • Start date Start date
S

sunil

I am creating an object of a button class
using the following code.
System.Windows.Forms.Button b=new
System.Windows.Forms.Button();

My requirement is i will acccept as a user input a fully
qualified class name like (ex:-System.Windows.Forms.Button)
How to create object of the class entered by the user.The
class name is not hard coded in my application.

Is it possible...
Please specify with an example...
 
My requirement is i will acccept as a user input a fully
qualified class name like (ex:-System.Windows.Forms.Button)
How to create object of the class entered by the user.The
class name is not hard coded in my application.
use System.Activator class
Is it possible...
Please specify with an example...

System.Activator.CreateInstance(Type.GetType(typeNameThatUserEntered));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top