(You are currently looking at the second edition version of this page. This page is also available for the third and first editions.)

Errata for Chapter 15: Letting your code speak more clearly with code contracts

P481, listing 15.17: Incorrect Ensures call

The postcondition in listing 15.17 is incorrect. Instead of this:

Contract.Ensures(text != null);

It should be:

Contract.Ensures(Contract.Result<string>() != null);

The generated XML changes in exactly the same way:

<ensures>Contract.Result&lt;string&gt;() != null</ensures>