Lambda “if” statement?

前端 未结 5 639
我寻月下人不归
我寻月下人不归 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:00

    as an inline if query I would use a ternary operator, so:

    (i.name != null ? set id to i.name : set id to i.inner.name)
    

提交回复
热议问题