将对象内的属性以及属性值输出
public static string ToProperties_V(this object obj) { if (obj == null) return ""; var s = obj.GetType(); StringBuilder app = new StringBuilder(); foreach (var item in s.GetProperties()) { app.Append($"{item.Name}:{item.GetValue(obj)}\n"); } return app.ToString().Trim(‘,‘); }
原文地址:https://www.cnblogs.com/lsgControl/p/9237088.html
时间: 2024-10-10 05:09:34