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