Using the Code Contracts API for design-by-contract in .NET. Code Contracts bring design-by-contract (DbC) to .NET through runtime and static contract checking of preconditions, postconditions, and object invariants. It also extends generated XML documentation. There are some known issues like slow build times and limitations with closures and iterators, but overall it provides an easy way to add design-by-contract principles to .NET code.