/// <summary> /// 列表打印 /// </summary> /// <param name="List"></param> /// <param name="loopCount"></param> /// <param name="spliter"></param> /// <param name="isShowBracket">是否用括号包起来</param> /// <returns></returns> public static string EnumerableToString(System.Collections.IEnumerable List, bool isShowBracket = false, string spliter = ",", int loopCount = 0) { loopCount++; StringBuilder sb = new StringBuilder(); int i = 0; if (isShowBracket) { sb.Append("["); } if (loopCount <= 3) { foreach (var v in List) { if (v is char || v is byte) { return(List.ToString()); } if (i != 0) { sb.Append(spliter); } sb.Append(ToString(v, isShowBracket, spliter, loopCount)); i++; } } if (isShowBracket) { sb.Append("]"); } return(sb.ToString()); }