62,243
社区成员




DataRow dr = DAL.GetDataRow(); //从数据库取得一条记录
Employee e = new Employee();//实例化一个对象
System.Reflection.PropertyInfo[] ps = e.GetType().GetProperties();//取得对象的所有属性
foreach(System.Reflection.PropertyInfo p in ps)
{
p.SetValue(e, Convert.ChangeType(dr[p.Name], p.PropertyType), null);//循环附值
}
using System;
using System.Collections.Generic;
using System.Text;
namespace text
{
public class zhj
{
public void Fun()
{
Console.WriteLine("sdsf");
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Assembly ass = Assembly.LoadFrom("E:\\text.dll");//获取程序集
object obj = ass.CreateInstance("text.zhj"); //获取实例
Type mytype = ass.GetType("text.zhj"); //获取类型
MethodInfo meth = mytype.GetMethod("Fun"); //获取方法
meth.Invoke(obj, null);
}
}
}