Created
July 16, 2019 22:10
-
-
Save dieseltravis/9040971eb126325d505ff01ecbe1efb4 to your computer and use it in GitHub Desktop.
lazily using LINQ Aggregate to reduce a List of strings to a CSV format (this is only for quick/dirty applications, it doesn't escape values)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //using System.Linq; | |
| List<List<string>> SomeData = new List<List<string>>(); | |
| // add values (first item as column names) | |
| SomeData.Add(new List<string> | |
| { | |
| "Id", | |
| "Name", | |
| "etc" | |
| }); | |
| string csv = SomeData.Aggregate("", (acc, list) => acc + string.Join(",", list) + "\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment