I have two extension methods:
public static string ToString(this List<object> list, char delimiter)
{
return ToString<object>(list, delimiter.ToString());
}
public static string ToString(this List<object> list, string delimiter)
{
return ToString<object>(list, delimiter);
}
When I use this:
char delimiter = ' ';
return tokens.ToString(delimiter);
It won't work. The char overload doesn't show up in the code completion list either. Can anybody tell me how to make this work?
EDIT
I accidentally forgot to mention that there are in fact 3 extension methods, the third being:
public static string ToString<T>(this List<T> list, string delimiter)
{
if (list.Count > 0)
{
string s = list[0].ToString();
for (int i = 1; i < list.Count; i++)
s += delimiter + list[i].ToString();
return s;
}
return "";
}
string.Join
... Which apparently is just as fast as StringBuilder, given you already have all the substrings in an IEnumerable of some sort.