Great .NET namespaces you weren’t aware of: System.Diagnostics.Contracts

Posted: (EET/GMT+2)

 

Code Contracts is originally a Microsoft Research project about putting static code rules into your C# code.

Code Contracts are available in the System.Diagnostics.Contracts namespace, and this namespace has been available since .NET 4.0, so it's been with us since 2009. But it's easy to forget about all those namespaces in the vast .NET library, and from time to time, it's good to refresh your mind about what's available.

For more information about .NET Code Contracts, check out this overview.