首页 > 其他 > 详细

获取属性值

时间:2015-12-29 12:34:58      阅读:142      评论:0      收藏:0      [点我收藏+]

 type.GetProperty("").GetValue(models[i], null);

标签类

public class Tag : ModelBase
    {
        public Tag() 
        {
            SortID = 99;
        }
        /// <summary>
        /// 产品标签名
        /// </summary>
        [Required(ErrorMessage = "标签名不能为空")]
        public string Title { get; set; }
        /// <summary>
        /// 该标签是否显示
        /// </summary>
        public bool IsShow { get; set; }
        /// <summary>
        /// 排序,初始99
        /// </summary>
        public int SortID { get; set; }

        public virtual ICollection<ProductTag> ProductTags { get; set; }
    }

var model=new Tag();

Type type = models[i].GetType();

 type.GetProperty("Title").GetValue(model, null);

根据属性名获取相应的值

 

获取属性值

原文:http://www.cnblogs.com/danlis/p/5085044.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!