开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜