如何对比实体类每个属性的前后变化差异?

   Apple app1 = new Apple();
            app1.name = "liu";
            app1.pice = "33";
            Apple app2 = new Apple();
            app2.name = "liu";
            app2.pice = "333";
             System.Reflection.PropertyInfo[] mPi = typeof(Apple).GetProperties();


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

                   string oldValue = pi.GetValue(app1, null).ToString();
                   string  newValue = pi.GetValue(app2, null).ToString();
                    if (oldValue !=newValue )
                    {
                        // 有差别的列出来
                    }
                 }

 public  class Apple
    { 
        public string name{get;set;}
        public string pice { get; set; }
    }

  

相关文章:

  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2021-11-17
  • 2022-01-24
  • 2021-09-11
  • 2022-12-23
  • 2021-10-14
  • 2022-01-18
相关资源
相似解决方案