I've previously waxed lyrical about the incredibly cool null-propagating operator coming in C# 6.0, but Jon Skeet recently raised an excellent point regarding event handlers.
_______________
Since the null-propagating operator can be used with method calls, what once had to be written as:
if (eventHandler != null) eventHandler(this, args);
Will soon be able to be written as:
eventHandler?.Invoke(this, args);
I think we can all agree that the latter is cleaner!
If you'd like to know more, then be sure to read the full post on Jon Skeet's blog and follow him if you aren't already, as he always goes into incredibly well considered depth on a topic!
No comments:
Post a Comment