Result(T) Method

Contract.Result(Of T) Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Represents the return value of a method or property.

Namespace:  System.Diagnostics.Contracts
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Shared Function Result(Of T) As T

Type Parameters

T

Type of return value of the enclosing method or property.

Return Value

Type: T
Return value of the enclosing method or property.

This method can be used only in the conditional expression for the Ensures contract.

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 As Object) As Integer Implements 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

End Function 'IArray.Add


Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft