📜  字符串 c# 字段 - C# 代码示例

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

代码示例1
public override String ToString()
    {
         Type objType = this.GetType();
         PropertyInfo[] propertyInfoList = objType.GetProperties();
         StringBuilder result = new StringBuilder();
         foreach (PropertyInfo propertyInfo in propertyInfoList)
             result.AppendFormat("{0}:{1},", propertyInfo.Name, propertyInfo.GetValue(this));
          
          return "{" + result.ToString() + "}";
     }