Anytime I need to make a string from a list that has some kind of delineation I have something like
string output = "";
for(int i=0; i<array.length; i++)
output += array[i] + ", ";
return output;
But this always adds a comma to the end where I don't want it. To avoid that I have to do
string output = "";
for(int i=0; i<array.length; i++)
output += array[i];
if(i != array.length - 1)
output += ", ";
return output;
Is there a more elegant way to achieve this goal?