This simple code creates a comma separated list. The beauty of this code is that most times you have to check for the last item and do something different or cut off the last character to make the list work well. This does all of that in a single line.
- for (int i = 0; i < tbl.Rows.Count; i++)
- DataRow dr = tbl.Rows[i];
- someString += dr["someValue"] + (i+1 == tbl.Rows.Count ? "" : ",");
You need to login to post a comment.