I have two different lists I want to export in single CSV file in ASP.NET
string listToString1= string.Join(\",\", list1.ToArray());
string listToString2= string
What you need is a Zip method:
List<string> list1 = new List<string>() { "Collection ID", "id1", "id2" , "id3" };
List<string> list2 = new List<string>() { "Collection Title", "Title1", "Title2", "Title3" };
var result = string.Join(" ",list1.Zip(list2, (f,l) => f + "," + l));
You need to make sure that you've added the System.Linq
to your using
directive though