How to extract List<int> from Dictionary<int, string>?
        Posted  
        
            by DaveDev
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by DaveDev
        
        
        
        Published on 2010-05-13T22:54:40Z
        Indexed on 
            2010/05/13
            23:04 UTC
        
        
        Read the original article
        Hit count: 199
        
c#
|linq-to-objects
I have a method that takes a List<int>, which is a list of IDs. The source of my data is a Dictionary<int, string> where the integers are what I want a list of. 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);
© Stack Overflow or respective owner