DEV Community

Discussion on: No more NullReferenceException for Lists in C#

Collapse
 
colinm9991 profile image
Colin M • Edited

If you're forgetting to instantiate objects then you have bigger problems to solve. This solution isn't readable, doesn't have clear intent and the out parameter is just confusing because it's not clear what kind of manipulation is happening when reading the method name. TryAdd would be better but still not clear, AddOrCreate would be one step closer but again, still confusing.

Keep it simple, initialize your objects, write clean code.