July 2017
Beginner
466 pages
9h 37m
English
The earlier versions of C# had some limitations on throwing exceptions from certain places, which caused developers to write more code to validate and raise exceptions. In C# 7.0, those limitations have been removed to reduce the overload.
The Null Coalescing operator now allows you to throw an exception in the middle of the expression without explicitly checking for null:
m_designation = designation ??
throw new ArgumentNullException(designation);
It is now possible to throw an exception from the Conditional operator too:
m_department = department == null ?
throw new ArgumentNullException(department) :
department;
C# 7.0 also allows you to throw an exception from expression-bodied member, as shown in the ...
Read now
Unlock full access