9
Answers

How Do I: Call a Class with a variable name?

Gustavo

Gustavo

14y
2.5k
1

Hello:

 

I posted this before but never got a solution, so I am asking again. Maybe someone else can complete this issue.

I want to be able to call a class with a variable name. The name of the class will be in a TextBox.

This is the code that I have at the moment:

 

string TheClass = textBoxClass_ID.Text;

object myDynamicClass = new Assembly.CreateInstance(TheClass);

myDynamicClass();

 

 

Can someone tell me what I am doing wrong?

Answers (9)