例如:
string str = "this.txtBox1"
然后把它弄成str.Text = "AA",
使其结果等同于C#语句: this.txtBox1.Text = "AA";或是将string str = "txtBox"  // 
然后有没有办法将其转换成一个txtBox对象?

解决方案 »

  1.   

    可以,比如,
    使用反射生成一个窗体的例子:
    Assembly assm = Assembly.LoadFrom("e:\\WindowsApplication.dll");
    Type TypeToLoad= assm.GetType("WindowsApplication.Form1");

    object obj;
    obj = Activator.CreateInstance(TypeToLoad);
    Form formToShow = null;
    formToShow = (Form)obj;
    formToShow.Show();另外参考,
    http://www.c-sharpcenter.com/CSNET/dynamicinvoke.asp
    http://www.c-sharpcorner.com/Code/2002/April/LoadingAssemblyInfo.aspDynamically load a class and execute a method in .NET
    http://www.codeproject.com/csharp/DynLoadClassInvokeMethod.asp