public static object FindLayoutTypes() { //地鼓、地裂、墙裂、井水、泉水 var sb = new StringBuilder(); sb.Append(getlayoutType("DG", "地鼓")); sb.Append(getlayoutType("DL", "地裂")); sb.Append(getlayoutType("QL", "墙裂")); sb.Append(getlayoutType("JS", "井水")); sb.Append(getlayoutType("QS", "泉水")); string str = sb.ToString(); if (str.EndsWith(",")) str = str.TrimEnd(','); return "[" + str + "]";//输出结果[{"key":"DG","value":"地鼓"},{"key":"DL","value":"地裂"},{"key":"QL","value":"墙裂"},{"key":"JS","value":"井水"},{"key":"QS","value":"泉水"}] } private static string getlayoutType(string key, string name) { return "{" + string.Format("\"key\":\"{0}\",\"value\":\"{1}\"", key, name) + "},"; }