We are commonly required to handle comma delimited lists while developing applications. In the past, I have used for loops or Array.Split() to handle these situations. At least I did until I discovered a handy little class in the .NET framework that is there to handle just such situations. The CommaDelimitedStringCollection class in the System.Configuration namespace behaves just like a normal generic list including methods for Add, Remove, IndexOf, Count, etc and can be looped through like any other list. This allows the flexibility of searching and sorting and also simplifies the handling of empty lists and removal of trailing commas when returning the comma delimited string. To convert to the comma delimited string all you have to do is call ToString() and you’re done.

More information can be found here

 
int i = 1;
string str1 = "A String";
string str2 = "Another String";
 
//assume System.Configuration has been imported
CommaDelimitedStringCollection strList = new CommaDelimitedStringCollection();
strList.Add(i.ToString());
strList.Add(str1);
strList.Add(str2);
 
Console.WriteLine("Count = " + strList.Count.ToString()); //output => Count = 3
Console.WriteLine("Index of '1' = " + strList.IndexOf("1")); //output => Index of '1' = 0
Console.WriteLine(strList.ToString());  //output => 1,A String,Another String