033
This commit is contained in:
parent
a91220d390
commit
9656918a40
@ -125,16 +125,16 @@ namespace DTLib
|
|||||||
builder.Append(parts[i].ToString());
|
builder.Append(parts[i].ToString());
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
public static string MergeToString<T>(this ICollection<T> collection, string separator)
|
public static string MergeToString<T>(this IEnumerable<T> collection, string separator)
|
||||||
{
|
{
|
||||||
if(collection.Count==0)
|
|
||||||
return "";
|
|
||||||
StringBuilder builder = new();
|
StringBuilder builder = new();
|
||||||
foreach(T elem in collection)
|
foreach(T elem in collection)
|
||||||
{
|
{
|
||||||
builder.Append(elem.ToString());
|
builder.Append(elem.ToString());
|
||||||
builder.Append(separator);
|
builder.Append(separator);
|
||||||
}
|
}
|
||||||
|
if (builder.Length==0)
|
||||||
|
return "";
|
||||||
builder.Remove(builder.Length-separator.Length, separator.Length);
|
builder.Remove(builder.Length-separator.Length, separator.Length);
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user