C# in Depth

Cover of C# in Depth
Order now (3rd edition)

Incorrect Ensures call

Chapter 15: Letting your code speak more clearly with code contracts: P481, listing 15.17

Created: 6/14/2011
Last updated: 6/14/2011
Severity: Technical error

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>