Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

List Of Dictionary to List of List<string> in LINQ

HI I have this example data which is in List<Dictionary<string,string>>

var menu = new List<Dictionary<string,string>> { new Dictionary<string, string> { { "Meal", "Pasta" }, { "Meal", "Pizza" } } , new Dictionary<string, string> { { "Entree", "Calamari Salad" } } },

I need to convert the above list to something like this

var menu = new List<List<string>> { new List<string> { "Meal:Pasta", "Meal:Pizza" }, new List<string> { "Entree:Calamari Salad" } };

how can I do this with LINQ query?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can try like below.

var result = menu.Select(x => x.Select(y => $"{y.Key}:{y.Value}"));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading