List of Int to CSV
List<int> list = new List<int>() {1,2,3,4,5};
Console.WriteLine(list.Select(f => f.ToString()).Aggregate((x, y) => x+","+y));
Output
1,2,3,4,5
List of string to CSV using string.join
List list = new List() {"1","2","3","4","5"};
string joined = string.Join("\",\"", list) ;
Output 1,2,3,4,5
List of string to CSV using string.join and string.Format
List list = new List() {"1","2","3","4","5"};
string joined = string.Format("\"{0}\"", string.Join("\",\"", list));
Output "1","2","3","4","5"
No comments:
Post a Comment