/// <summary>
/// 根据属性名称获取属性值
/// </summary>
/// <param name="entity">实体</param>
/// <param name="propertyName">属性名称</param>
/// <returns></returns>
private object GetPropertyValue(T entity, string propertyName)
{
object result = null;
Type entityType = typeof(T);
try
{
PropertyInfo proInfo = entityType.GetProperty(propertyName);
result = proInfo.GetValue(entity);
}
catch (Exception)
{
}
return result;
}
c#根据属性名称获取泛型的属性值
最新推荐文章于 2023-03-01 18:48:30 发布