Format string array to character seperated list
Ok so I've been needing a way to take an array of strings and make a list of comma or whatever character and turn it into one big string of items. Today I finally found a quick and painless (to the coder, maybe not the compiler) solution.
string[] ids = {"2343","2344","2345"};
string idString = String.Join(",",ids);
Response.Write(idString);
After this code you get one string with all the items in the array seperated by a comma. Of course just chaning the char in the String.Join methods gives you different results.
string[] ids = {"2343","2344","2345"};
string idString = String.Join(",",ids);
Response.Write(idString);
After this code you get one string with all the items in the array seperated by a comma. Of course just chaning the char in the String.Join methods gives you different results.
Comments