Hmm. Does this help? I'm a bit rusty so don't trust this.
Code:
static void Main(string[] args)
{
Question[] allQuestions = {
new Question { Context = "1234a", Version = DateTime.Now.AddDays(-2)},
new Question { Context = "1234a", Version = DateTime.Now.AddDays(-1)},
new Question { Context = "1233a", Version = DateTime.Now.AddDays(-2)},
new Question { Context = "1233a", Version = DateTime.Now.AddDays(-1)}
};
var mostRecent =
from q in allQuestions
orderby q.Version
group q by q.Context into r
select new
{
Context = r.Key,
Version = r.Last().Version
};
foreach (var i in mostRecent)
Console.WriteLine(i.Context + " * " + i.Version);
}
Bookmarks