[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)
Visual Basic (Declaration)
Public Shared Function Result(Of T) As T
Dim returnValue As T
returnValue = Contract.Result()
public static T Result<T>()
public:
generic<typename T>
static T Result()
static member Result : unit -> '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
'
'ToDo: Error processing original source shown below
' return default(int);
End Function 'IArray.Add
int IArray.Add(Object value)
{
// Returns the index in which an item was inserted.
Contract.Ensures(Contract.Result<int>() >= -1);
Contract.Ensures(Contract.Result<int>() < ((IArray)this).Count);
return default(int);
}
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.
.NET Framework
Supported in: 4
.NET Framework Client Profile
Supported in: 4
Reference