Shorthand for nested null checking C#

后端 未结 5 1680
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 09:38

As far as I know there is not a significantly more elegant way to write the following....

string src;
if((ParentContent!= null)
    &&am         


        
5条回答
  •  萌比男神i
    2020-12-17 10:02

    It's been suggested and apparently rejected by the team:

    A bit more C# syntactic sugar for nulls

    The proposed syntax would have looked like a.?b.?c() - very useful, and unambiguous.

    I'd really like to see it too, but doesn't look like it'll happen. Maybe if enough people vote on it!

提交回复
热议问题