Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6935957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:10:16+00:00 2026-05-27T12:10:16+00:00

I had overheard some discussion in my office recently about .Net Contracts however, when

  • 0

I had overheard some discussion in my office recently about .Net “Contracts” however, when I asked some of my fellow employees, not of them could easily explain to me what they were for, or what they even were.

Does anyone have any resources, explanations, and perhaps a tutorial on their usage?

Thanks,

Paul

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:10:17+00:00Added an answer on May 27, 2026 at 12:10 pm

    Code Contracts were introduced in .NET 4.0 and they provide a language-agnostic method to express coding assumptions in programs.

    They basically allow you to check for pre-conditions, post-conditions and other features and can greatly improve the testing process and the eventual quality of code that is being written.

    From Microsoft:
     

    • Runtime Checking. Our binary rewriter modifies a program by injecting    the contracts, which are checked as part of program> execution. Rewritten programs improve testability: each contract acts as an oracle, giving a test run a pass/fail indication. Automatic testing tools, such as Pex, take advantage of contracts to generate more meaningful unit tests by filtering out meaningless test arguments that don’t satisfy the pre-conditions. 

    • Static Checking. Our static checker can decide if there are any contract violations without even running the program! It checks for implicit contracts, such as null    dereferences and array bounds, as well as the explicit contracts.

    • Documentation Generation. Our documentation generator augments existing XML doc files with contract information. There are also new style sheets that can be used with Sandcastle so that the generated documentation pages have contract sections.

    Learn More:

    • Code Contracts | Microsoft Research
    • Code Contracts Overview Video and Tutorial by Greg Young | InfoQ
    • Code Contracts | Microsoft DevLabs
    • Tutorial on Using Code Contracts | jarloo.com
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a debate about macros and their readability. I think that in some
I had some discussion related to the use of properties and instance variables at
I'm in need of some clarification. I've been reading about REST, and building RESTful
I have a project that I have recently started working on seriously but had
I had set up my thread pool like this: ThreadPool.SetMaxThreads(10000, 10000); ThreadPool.SetMinThreads(20, 20); However,
Gamemaker is a neat tool which allows for some good RAD. However it has
We had a debate in the office with respect to audit logging of messages
I had a problem with a thread locking up for some still unknown reason
A while back I overheard some very experienced web developer describe an ideal (in
If I had a million images, would it be better to store them in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.