score:3

Accepted answer
var amounts = files.todictionary(
        file => new {file.name,file.year}, file => file.amount);

foreach(var name in files.select(file => file.name).distinct())
foreach(var year in files.select(file => file.year).distinct())
{
    decimal amount;
    if(!amounts.trygetvalue(new {file.name,file.year}, out amount) amount = 0m;
    console.writeline("name={0}, year={1}, amount={2}",
                  name, year, amount);
}

score:0

public class file
{
    public file() { this.amout = 0; }

    public string name{get;set;}
    public int year{get;set;}
    public decimal amount{get;set;}
}

Related Query

More Query from same tag