Type type = Type.GetType("System.Windows.Forms.TextBox")?
TextBox obj = (TextBox)Activator.CreateInstance(type);
为什么会出现“空引用”?
该怎样写

解决方案 »

  1.   

    string assemblyQualifiedName =  typeof(System.Windows.Forms.Form).AssemblyQualifiedName;
    string assemblyInformation = assemblyQualifiedName.Substring(assemblyQualifiedName.IndexOf(","));
    Type type = Type.GetType("System.Windows.Forms.TextBox" + assemblyInformation);;
    TextBox obj = (TextBox)Activator.CreateInstance(type);
    //this.Controls.Add(obj);
      

  2.   

    http://blog.csdn.net/fangxinggood/archive/2005/07/29/438404.aspx
      

  3.   

    要这么麻烦吗?我只是想通过"System.Windows.Forms.TextBox"创建一个实例
    有简单一点的办法吗?