Answers for "dictionary turn values to list c#"

C#
1

c# dictionary values to list

var items = myDictionary.Values.ToList();

//Use Linq if you want to flattern your lists
var items = myDictionary.SelectMany (d => d.Value).ToList();
Posted by: Guest on July-03-2021
1

dictionary to list c#

Dictionary<string, string> dicNumber = new Dictionary<string, string>();
List<string> listNumber = new List<string>();

dicNumber.Add("1", "First");
dicNumber.Add("2", "Second");
dicNumber.Add("3", "Third");

listNumber = dicNumber.Select(kvp => kvp.Key).ToList();
// Or:
listNumber = dicNumber.Keys.ToList();
Posted by: Guest on August-17-2021

Code answers related to "dictionary turn values to list c#"

C# Answers by Framework

Browse Popular Code Answers by Language