C++开发博客CSDN

循环类里面的每一个属性

         

   Type type = typeof(类名);

            System.Reflection.PropertyInfo[] myPropertyInfo;
            myPropertyInfo = type.GetProperties();

            for (int i =0; i < myPropertyInfo.Length; i++)
            {
                     Amount amount= (Amount)myPropertyInfo[i].GetValue(Statictis, null);

                    amount.CDF= Math.Round(amount.CDF, 2);

                    myPropertyInfo[i].SetValue(Statictis, amount, null);
                
            }
       

posted @ 2013-01-11 11:27  纳凉亭子  阅读(254)  评论(0编辑  收藏  举报