Contract..::.Result<(Of <(T>)>) Method Home
This page is specific to:.NET Framework Version:4.0
.NET Framework Class Library
Contract..::.Result<(Of <(T>)>) Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents the return value of a method or property.

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

'Usage

Dim returnValue As T

returnValue = Contract.Result()

'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.
Remarks

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

Examples

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
    '
    'ToDo: Error processing original source shown below
    '        return default(int);
End Function 'IArray.Add


Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4
See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View