Created
February 14, 2012 10:27
-
-
Save jagregory/1825592 to your computer and use it in GitHub Desktop.
Ways of handling null collections and AddRange
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
// a) | |
if (items != null) | |
collection.AddRange(items) | |
// b) | |
collection.AddRange(items ?? new Foo[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@leniel How do you call this extension method on
self
ifself
isnull
? It seems like it would cause some exception))