码迷,mamicode.com
首页 > Windows程序 > 详细

C# 根据类型名称 生成实体 调用方法

时间:2016-06-27 17:36:48      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:

            System.Reflection.Assembly ass = System.Reflection.Assembly.Load("项目名称或者DLL");
            //System.Threading.Tasks
            Type type = ass.GetType("实体的完整名称不带.cs");
            var entity = Activator.CreateInstance(type);
            //参数 数组的个数对应方法的参数个数
            object[] methodParams = new object[1];
            methodParams[0] = "tablename";
            //需要调用的方法
            MethodInfo method = type.GetMethod("method");
            method.Invoke(entity, methodParams);

 

C# 根据类型名称 生成实体 调用方法

标签:

原文地址:http://www.cnblogs.com/wangshisuifeng/p/5620465.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!