使用字符串的值来创建新的表单对象

cvo*_*cvo 2 c# string winforms

我有一个启动的主表单,然后它可以转到我创建的任何其他表单.但是踢球者是我写了一个我调用的类,它返回一个带有要转到的表单名称的字符串.

目前我没有这个工作,所以我从形式到这样的形式(静态编写的链接代码):

this.Hide();
CloudAccess nextForm1 = new CloudAccess(); 
   //Where CloudAccess is the class of the next form.
nextForm1.ShowDialog();
Run Code Online (Sandbox Code Playgroud)

我想要的是这样的:

FormController pick = new FormController();
   //Where FormController is the Class I create an object of and ask what's next
string next = pick.whereToGo(); //lets say it returns "CloudAccess"
this.Hide();
next nextForm1 = new next(); //next is desired to be the contents of the string
nextForm1.ShowDialog();
Run Code Online (Sandbox Code Playgroud)

问题是我不知道如何使用返回的字符串来创建新对象并使用它.我一直在研究像这样的Invoke和Reflection主题:使用字符串值来创建新实例 但我是C#的新手,我不知道如何将其应用于此场景.

思考?谢谢!

cvo*_*cvo 5

这是fejejosco所说的工作代码:

string asdf = "CloudAccess";
Type CAType = Type.GetType("namespace." + asdf);
Form nextForm2 = (Form)Activator.CreateInstance(CAType);
nextForm2.ShowDialog();
Run Code Online (Sandbox Code Playgroud)

谢谢!