Code Contracts at runtime

DarthVader picture DarthVader · Jul 14, 2011 · Viewed 9.6k times · Source

As far as I read in a nutshell book, code contracts could degrade the runtime performance.

Is it possible to disable code contracts in production?

Answer

Jon Skeet picture Jon Skeet · Jul 14, 2011

The user manual explains this in a fair amount of detail - there are all kinds of options you can have. Each build configuration can have different settings for which contracts are checked at execution time, and it's not an "all or nothing" choice - you can enforce all, some or none of the contracts, based on settings which can be tweaked in Visual Studio.