advertise with us

.NET 7 to include new ThrowIfNullOrEmpty ArgumentException guard clause

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 👍🏻


Need Help with Your C# Projects?

We offer expert support and development services for projects of any size. Contact us for a free consultation and see how we can help you succeed.

CONTACT US NOW