[英]C# CodeDom generic add “out” parameter
我喜欢创建一个具有通用参数的功能:
公共接口IInterfaceMethod < out T0>:其中T0:IInterface2
所以我创建了一个新的CodeTypeParameter并将其添加为约束。 那么如何创建“输出”值?
谢谢
您只能将T0
泛型类型放在此接口内的“ out”位置:
你不能:
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.