The following example shows how to use the Result(Of T) method to specify an expected return value. This code example is part of a larger example provided for the ContractClassAttribute class.
Function Add(ByVal value AsObject) AsIntegerImplements IArray.Add
' Returns the index in which an item was inserted.
Contract.Ensures(Contract.Result(Of Integer)() >= -1) '
Contract.Ensures(Contract.Result(Of Integer)() < CType(Me, IArray).Count) 'Return 0
EndFunction'IArray.Add