The difference in the contract. Requirements and contract.

I searched for the difference on the Microsoft website, but I see no difference. links to the site below

Any further explanation would be wonderful.

Using visual studio c #

+7
c #
source share
1 answer

Requires is a prerequisite, meaning that the specified condition must be true before for the called method. Ensures is a postcondition, meaning that the method guarantees that the specified condition is true after the method call completes.

Prerequisites and / or postconditions may be violated during the execution of the method: tests are performed upon entry and exit of the method, respectively. An invariant condition is a contract that states that the specified condition is always fulfilled.

Read Bertrand Meyer Object Oriented Software for more details [more details] more. This Mayer article is shorter [much shorter].

+7
source share

All Articles