📜  c# 打印对象的所有属性值 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:50.731000             🧑  作者: Mango

代码示例1
public static string PropertyList(this object obj)
{
  var props = obj.GetType().GetProperties();
  var sb = new StringBuilder();
  foreach (var p in props)
  {
    sb.AppendLine(p.Name + ": " + p.GetValue(obj, null));
  }
  return sb.ToString();
}