ref and out parameters in C# and cannot be marked as variant

后端 未结 4 1977
-上瘾入骨i
-上瘾入骨i 2020-11-29 05:09

What does the statement mean?

From here

ref and out parameters in C# and cannot be marked as variant.

1) Does it mean

4条回答
  •  自闭症患者
    2020-11-29 05:28

    It means you can't have the following declaration:

    public delegate R MyDelegate(ref A arg);
    

    Edit: @Eric Lippert corrected me that this one is still legal:

    public delegate void MyDelegate(A arg, out R s);
    

    It actually makes sense, since the R generic parameter is not marked as a variant, so it doesn't violate the rule. However, this one is still illegal:

    public delegate void MyDelegate(A arg, out R s);
    

提交回复
热议问题