class ClassA { public int a = 0; private string s = "ss"; public string SS { get { return s; } set { s = value; } } public void ttt() { MessageBox.Show("rrrrr"); } public static bool Update(Object o) { PropertyInfo p = o.GetType().GetProperty("SS"); { string s = (string)p.GetValue(o, null); //获取属性 s = s + "00000"; p.SetValue(o, s, null); //设置属性 } FieldInfo f = o.GetType().GetField("a"); { int y = (int)f.GetValue(o); y = y + 100; f.SetValue(o, y); } MethodInfo m = o.GetType().GetMethod("ttt"); //获取方法 m.Invoke(o, null); //调用方法 return true; } }
((ClassA)o).Methed();
{
public int a = 0;
private string s = "ss";
public string SS
{
get { return s; }
set { s = value; } }
public void ttt()
{
MessageBox.Show("rrrrr"); } public static bool Update(Object o)
{
PropertyInfo p = o.GetType().GetProperty("SS");
{
string s = (string)p.GetValue(o, null); //获取属性
s = s + "00000";
p.SetValue(o, s, null); //设置属性
} FieldInfo f = o.GetType().GetField("a");
{
int y = (int)f.GetValue(o);
y = y + 100;
f.SetValue(o, y);
}
MethodInfo m = o.GetType().GetMethod("ttt"); //获取方法
m.Invoke(o, null); //调用方法
return true;
}
}