Re: Linq queries on a List<KeyValuePair<>>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marc Gravell

    #1

    Re: Linq queries on a List<KeyValuePair<>>

    Well, I'd have to wonder why you don't just use Dictionary<,/
    SortedList<,/ SortedDictionar y<,(and just use .Keys and .Values)

    But something like below:

    List<KeyValuePa ir<DateTime, double>list = null;
    List<DateTimeke ys = list.Select(x =x.Key).ToList( );
    List<doublevalu es = list.Select(x =x.Value).ToLis t();
    List<doublevalu esByKey = list.OrderBy(x =x.Key)
    .Select(x =x.Value).ToLis t();

    You could also use the alternative LINQ syntax, but the above should work.

    Marc
Working...