How to call function inside linq anonymous function
I want to do something like that:
var result = genericList.ToDictionary(CalculateSomething(x => x.Date), y => y.Point);
So according with that example i want to call CalculateSomething()
inside .ToDictionary()
is there any ways i can do that, i may do that through foreach
loop but i would like to keep linq
syntax开发者_如何学C.
You've just got your lambda syntax wrong:
var result = genericList.ToDictionary(x => CalculateSomething(x.Date), y => y.Point);
var result = genericList.ToDictionary(x => CalculateSomething(x.Date), y => y.Point);
精彩评论