-1
我喜歡創造具有通用參數的Funktion:C#的CodeDOM通用添加 「out」 參數
公共接口IInterfaceMethod < 出 T0>: 其中T0:IInterface2
所以我創建了一個新的CodeTypeParameter並將其添加爲約束。那麼我怎樣才能創造出「價值」?
感謝
我喜歡創造具有通用參數的Funktion:C#的CodeDOM通用添加 「out」 參數
公共接口IInterfaceMethod < 出 T0>: 其中T0:IInterface2
所以我創建了一個新的CodeTypeParameter並將其添加爲約束。那麼我怎樣才能創造出「價值」?
感謝
你只能把T0
泛型類型在這個界面裏面的「出」的位置:
您不能:
out
參數)這是你的接口的例子:
public interface IInterfaceMethod<out T0>
where T0 : IInterface2
{
T0 GetterOnly { get; }
T0 MethodReturnValue();
}
,而這是非法的:
public interface IInterfaceMethod<out T0>
where T0 : IInterface2
{
T0 GetterAndSetter { get; set; }
void MethodParameter(T0 value);
void MethodOutParameter(out T0 value);
}
你只能*回報*的,價值觀從此接口輸入,作爲getter-only屬性的返回值或作爲方法的返回值。 –