反射遍历 实现 实体修改前后 不同

来源:互联网 发布:淘宝店铺账号能改吗 编辑:程序博客网 时间:2024/05/08 08:16



转自:http://bbs.csdn.net/topics/390614521


System.Reflection.PropertyInfo[] mPi = typeof(InfoModel).GetProperties();


                for (int i = 0; i < mPi.Length; i++)
                {
                    System.Reflection.PropertyInfo pi = mPi[i];

                    oldValue = pi.GetValue(oldModel, null).ToString();
                    newValue = pi.GetValue(newModel, null).ToString();
                    if (oldValue !=newValue )
                    {
                         有差别的列出来
                    }
                 }

}

0 0
原创粉丝点击