Contract.ValueAtReturn<T>(T) 方法

定義

表示從方法傳回時的最後 (輸出) out 參數值。Represents the final (output) value of an out parameter when returning from a method.

public:
generic <typename T>
 static T ValueAtReturn([Runtime::InteropServices::Out] T % value);
public static T ValueAtReturn<T> (out T value);
static member ValueAtReturn : 'T -> 'T
Public Shared Function ValueAtReturn(Of T) (ByRef value As T) As T

類型參數

T

out 參數的類型。The type of the out parameter.

參數

value
T

out 參數。The out parameter.

傳回

T

out 參數的輸出值。The output value of the out parameter.

備註

這個方法只能用在 Ensures 合約的條件運算式中。This method can be used only in the conditional expression for the Ensures contract. 如同 OldValue 方法,只要編譯器能夠推斷其類型,您就可以省略泛型型別引數。As with the OldValue method, you can omit the generic type parameter whenever the compiler is able to infer its type. 合約重寫器會將方法呼叫取代為 out 參數的值。The contract rewriter replaces the method call with the value of the out parameter. ValueAtReturn 方法只會出現在後置條件中。The ValueAtReturn method may appear only in postconditions. 方法的引數必須是 out 參數,或是結構 out 參數的欄位。The argument to the method must be an out parameter or a field of a structure out parameter. 參考結構建構函式後置條件中的欄位時,後者也很有用。The latter is also useful when referring to fields in the postcondition of a structure constructor.

適用於