Lambda “if” statement?

前端 未结 5 628
我寻月下人不归
我寻月下人不归 2021-02-04 13:36

I have 2 objects, both of which I want to convert to dictionarys. I use toDictionary<>().

The lambda expression for one object to get the key is (i => i.name). For th

5条回答
  •  一生所求
    2021-02-04 14:09

    Why don't you give each object a ToDictionary method of their own, as they obviously have their own behaviours in this case.

    If you can't add to the objects, because you don't own them, you can always write extension methods for them.

    Any reason your trying to force feed them into one "common" function?

提交回复
热议问题