如何将一个字符串转换为变量或对象或方法名
实现下面的效果
string vtype="SqlCommand";
SqlCommand cmd=new vtype();

解决方案 »

  1.   

    string tostr="ToString()";
    int myint=1234;
    Response.write(myint.tostr);
    -------------------------------------
    string tostr="ToString()";
    int myint=1234;
    Response.write(myint.tostr);
    ----------------------------------------
    string mytype="SqlDbType.VarChar";
    para=new SqlParameter("@wID",mytype,4);
      

  2.   

    php 里有$$myvaraspx 里不可能没有同样的东西吧?
      

  3.   

    using System.Reflection;Assembly ass = Assembly.Load("System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", null);
    SqlCommand cmd  =ass.CreateInstance("System.Data.SqlClient.SqlCommand") as SqlCommand;