No, you cannot do this. Also, what would you achieve, since you need to assign it to a “static” type, in your case, Button - so why not just say it normally:
Button b = (Button)control;
You can use, check if your control type is of type:
Type t = TypeFromString(name);
bool isInstanceOf = t.IsInstanceOfType(control);
Edit: To create an object without entering it at compile time, you can use the Activator class:
object obj = Activator.CreateInstance(TypeFromString(name));
Button button = (Button)obj;
source
share