标签:
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