Skip to content

Instantly share code, notes, and snippets.

@drZool
Created April 20, 2018 09:22
Show Gist options
  • Select an option

  • Save drZool/cb1aa3dcea6a7c1dcf54b1120506d90d to your computer and use it in GitHub Desktop.

Select an option

Save drZool/cb1aa3dcea6a7c1dcf54b1120506d90d to your computer and use it in GitHub Desktop.
String Join IList extension
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System;
public static class ListExtensions
{
static public string Join<T> (this IList<T> list, string separator)
{
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < list.Count; ++i) {
if (i > 0)
sb.Append (separator);
sb.Append (list [i].ToString ());
}
return sb.ToString ();
}
static public string Join<T> (this IList<T> list, string separator, Func<T, string> ToString)
{
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < list.Count; ++i) {
if (i > 0)
sb.Append (separator);
sb.Append (ToString (list [i]));
}
return sb.ToString ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment