• [C#]反射相关


    //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");

    反射窗体的代码:

    Assembly ass = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + "\Test.dll");
    Form fr = ass.CreateInstance("Test.Form1") as Form;
    Type type = Type.GetType("Test2.Form1");
    Form fr = Activator.CreateInstance(type) as Form;
  • 相关阅读:
    flask 知识积累
    python中下划线
    pipenv知识积累
    shell知识积累
    AttributeError: type object 'testClass' has no attribute 'testMothod'
    python知识积累
    补全爬取的url
    linux 的基本命令
    Python里的拷贝
    关于第一次java课的感想
  • 原文地址:https://www.cnblogs.com/z5337/p/7192682.html
Copyright © 2020-2023  润新知