Files
trail-into-darkness/Packages/com.jovian.utilties/Runtime/ArrayUtility.cs

36 lines
1010 B
C#

using System.Collections;
using System.Text;
namespace Jovian.Utilities {
public static class ArrayUtility {
public static string ListToString(this IList list, bool newLinePerEntry = false) {
if(list == null) {
return "<NULL>";
}
StringBuilder sb = new();
sb.Append("[");
sb.Append(list.Count);
sb.Append("]{");
if(newLinePerEntry) {
sb.AppendLine();
}
for(int i = 0, c = list.Count; i < c; i++) {
sb.Append(list[i]);
if(i < c - 1) {
if(newLinePerEntry) {
sb.AppendLine(",");
}
else {
sb.Append(", ");
}
}
}
if(newLinePerEntry) {
sb.AppendLine();
}
sb.Append("}");
return sb.ToString();
}
}
}