Sams Teach Yourself C# 5.0 in 24 Hours by Scott J. Dorman

Sams Teach Yourself C# 5.0 in 24 Hours by Scott J. Dorman

Author:Scott J. Dorman [Dorman, Scott J.]
Language: eng
Format: epub, mobi
Publisher: Pearson Education
Published: 2012-11-20T06:00:00+00:00


int result = dividend / divisor;

return result;

}

* * *

In order to write this postcondition, it was necessary to change the implementation so the result of the division was captured in a local variable. Because this isn’t always practical, the code contracts library provides the Contract.Result<T> method to refer to the actual return value. Using Contract.Result<T> would allow the Calculate method to be written as shown in Listing 11.11.

* * *

Caution: Contract.Result<T> and void Methods

Methods that have a void return type cannot use Contract.Result<T> within their postconditions.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.