需要大到小才能
var data = new Person[]
{
new Person() { Name = "code6421", Age = 10},
new Person() { Name = "code64212", Age = 19},
new Person() { Name = "bill", Age = 29},
new Person() { Name = "tom", Age = 37},
new Person() { Name = "tom2", Age = 45},
new Person() { Name = "tom1", Age = 06}
};
var map = new Dictionary<int, double>()
{
{30, 0.75},
{20, 0.65},
{10, 0.55},
{05, 0.45}
};
//map is be ordered first.
var result = map.Join(data, m => m.Key, d => map.FirstOrDefault(a => d.Age > a.Key).Key,
(m, d) => new { Person = d, Value = m.Value });
PrintData(result, (s) => Console.WriteLine($"{s.Person.Name}:{s.Value}"));
0 留言