做了一个方法,传入某对象,如果是string类型则后面加个“1”
加断点propertys的值是{System.Reflection.PropertyInfo[0]}
进不到 foreach循环里,请高手看看这是怎么回事啊?
调用代码是:bm = getObject(bm);
public T getObject(T t)
{
string temp = "";
System.Reflection.PropertyInfo[] propertys = t.GetType().GetProperties();
foreach (System.Reflection.PropertyInfo p in propertys)
{
if (p.PropertyType == typeof(string))
{
temp = p.GetValue(t, null).ToString();
p.SetValue(t, temp+"1", null);
}
}
return t;
}