How to extract List <int> from dictionary <int, string>?
I have a method that accepts List<int>
which is a list of ids. The source of my data is Dictionary<int, string>
where integers are what I want in the list. Is there a better way to get this than the following code?
var list = new List<int>();
foreach (var kvp in myDictionary)
{
list.Add(pair.Key);
}
ExecuteMyMethod(list);
+2
a source to share