In .NET 6 Microsoft introduced the ArgumentException.ThrowIfNull guard clause and in .NET 7 (Preview 4) they have introduced ArgumentException.ThrowIfNullOrEmpty.
Using these kind of guard clauses instead of if statement checks results in cleaner code. Here is a example (from Steven Giesel on LinkedIn) with the new guard clause…
I really like it, hopefully Microsoft can continue to add more guard clauses in future .NET releases.
Thanks to Steven Giesel for the heads up about this 👍🏻