日期:2014-05-18 浏览次数:20834 次
Dictionary<int, int> dic = new Dictionary<int, int> { { 1, -1 }, { 2, -1 }, { 3, -1 }, { 4, 2 }, { 5, 2 }, { 6, 5 }, { 7, 1 }, { 8, 2 }, { 9, 1 }, { 10, 7 }};
var q = dic .Where(x => x.Value == -1) .OrderBy(x => x.Key) .Select(x => x.Key) .ToList(); Assert.AreEqual(1, q[0]); Assert.AreEqual(2, q[1]); Assert.AreEqual(3, q[2]);
------解决方案--------------------