C#利用反射获取对象属性值

it2026-02-10  1

public static string GetObjectPropertyValue<T>(T t, string propertyname){     Type type = typeof(T);

      PropertyInfo property = type.GetProperty(propertyname);

      if (property == null) return string.Empty;

      object o = property.GetValue(t, null);

      if (o == null) return string.Empty;

      return o.ToString(); }

转载于:https://www.cnblogs.com/fengguangqin/archive/2010/05/12/1733894.html

相关资源:c# 反射获取传入对象的属性拼接sql语句实现增、删、改、查
最新回复(0)