I have a StringBuilder and I'm trying to append parameters from multiple lists like this:
var sb = new StringBuilder();
var list1 = new List<string>() { "a", "b", "c" }
var list2 = new List<string>() { "d", "e" }
sb.AppendFormat(" {0}, {1}, {2}, {3}, {4} ", list1, list2);
I get an exception :
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
What I did to make it work is create a temporary list
var temp = new List<string>();
temp.AddRange(list1);
temp.AddRange(list2);
sb.AppendFormat(" {0}, {1} ,{2} ,{3} ,{4} ", new List().Add);
Is there a more elegant way to do this ?