DEV Community

Discussion on: Dealing with Nothing in C# - The Null Object Pattern

Collapse
 
jamesmh profile image
James Hickey

Very well written and straightforward - thanks!

Using the same pattern but in the context of collections, C# has ways to define "empty" collections. For example, a collection of IEnumerable can use the Null Object pattern this way:

IEnumerable<SomeModel> collection = Enumerable.Empty<SomeModel>();

Looking forward to the next article!