Created
January 3, 2019 15:31
-
-
Save scottashipp/e14c7bc6400526c5449ca505df624140 to your computer and use it in GitHub Desktop.
Use of Null-Conditional operator in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int? length = customers?.Length; // null if customers is null | |
Customer first = customers?[0]; // null if customers is null | |
int? count = customers?[0]?.Orders?.Count(); // null if customers, the first customer, or Orders is null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is from the C# documentation