コンパイラ エラー 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()
{
}
}