Aug 12, 2015

Covnvert List to String in C#

Sometime developer required convert List to comma separated string.

So here we just quick look of string.Join code magic and get our expected result.

List number = new List();
number.Add(1);
number.Add(4);
number.Add(50);
number.Add(78);

string strNumber = string.Join(",", number.ToArray());

Response.Write(strNumber);

Output: 1,4,50,78

Hope you enjoy it!!

1 comment: