Created
December 13, 2015 15:27
-
-
Save YuvalItzchakov/5b728c1849dfa871ceb6 to your computer and use it in GitHub Desktop.
This file contains 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
List<int> collection = GetCollection(); | |
if ((collection?.Any(x => x > 5)) | |
{ | |
// Is the collection null, or isn't there any element? | |
} | |
else | |
{ | |
// I want to access the list here, need to add a null check: | |
if (collection != null) | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment