[C#]反射相关

时间:2021-08-15 00:52:08

//Type type = DataHelper.Instance.GetType(); //MethodInfo[] infos = type.GetMethods(BindingFlags.Instance | BindingFlags.Public); Assembly ass = System.Reflection.Assembly.LoadFrom(@"D:\DBHelper.dll"); //Type type = ass.GetType("DBHelper.SqlConn"); Type type = ass.GetType("DBHelper.Datahelper",false,true); MemberInfo[] infos = type.GetMembers(); //object reflectTest = Activator.CreateInstance(type,false); //MethodInfo info = type.GetMethod("GetConn", new Type[] { typeof(string) }); //string conn = (string)info.Invoke(reflectTest, new string[] { "D" }); //string conn = DBHelper.SqlConn.GetConn("D"); //DataTable dt = DataHelper.Instance.GetDataTable("select * from C", "D");