C# 反射遍历对象所有属性


        [TestMethod]
        public void Test6()
        {
            List<RepaymentRecord> repaymentList = new List<RepaymentRecord>();

            StringBuilder msg = new StringBuilder();
            RepaymentRecord entity = new RepaymentRecord();
            entity.Month1 = "100";
            entity.Month18 = "900";
            entity.Month24 = "322";
            foreach (PropertyInfo p in entity.GetType().GetProperties())
            {
                msg.AppendFormat("{0},{1}", p.Name, p.GetValue(entity));
            }
            var result = msg;
            Assert.IsNotNull(result);
        }
View Code

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM