Created
April 20, 2018 09:22
-
-
Save drZool/cb1aa3dcea6a7c1dcf54b1120506d90d to your computer and use it in GitHub Desktop.
String Join IList extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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