Alongside nullable value types C# 2.0 a new ?? operator was added to make working with nulls easier.
Code
csharp
intro = post.Intro ?? MakeIntro(post);csharp
intro = post.Intro != null ? post.Intro : MakeIntro(post);Notes
- The null-conditional operators C# 6.0 can also help with similar scenarios
- Null coalescing assignment C# 8.0 adds
??=to assign only when the target is null