Type t = tc.GetType();//获得该类的Type
foreach (PropertyInfo pi in t.GetProperties)
{
object value1 = pi.GetValue(tc, null));//用pi.GetValue获得值
string name = pi.Name;//获得属性的名字
//获得属性的类型
if(value1.GetType() == typeof(int))
{
//进行你想要的操作
}
}
注意:必须要设置了get 和set方法的属性,反射才能获得该属性
public int Pid
{
get { return pid; }
set { pid = value; }
}