编译器错误 CS0662
更新:2007 年 11 月
错误消息
“method”不能在 ref 参数上仅指定 Out 属性。请同时使用 In 和 Out 属性,或者两者都不使用。
接口方法的一个参数使用了只有 Out 属性的 ref。使用 Out 属性的 ref 参数还必须使用 In 属性。
下面的示例生成 CS0662:
// CS0662.cs
using System.Runtime.InteropServices;
interface I
{
void method([Out] ref int i); // CS0662
// try one of the following lines instead
// void method(ref int i);
// void method([Out, In]ref int i);
}
class test
{
public static void Main()
{
}
}