Only strings can contain items separated by commas, and every item in the sting must also be a string - lists contain the items in their "native" format.
However it's not difficult at all to create a string from a List using
string.Join
:
List<int> myList = new List<int>() { 1, 2, 3, 4, 666, 17, 42 };
string commaSeparated = string.Join(",", myList);
This will use the default
ToString
implementation so it will work with any class that overrides
ToString
.
Alternatively, in your specific case, just use a StringBuilder:
StringBuilder sb = new StringBuilder();
string sep = "";
foreach (DataRow row in dt.Rows)
{
sb.AppendFormat("{0}{1}", sep, (string)Convert.ToString(row["partDesc"]));
sep = ",";
}
string commaSeparated = sb.ToString();