Leer en inglés

Compartir a través de


Error del compilador CS0662

'method' no puede especificar solo el atributo Out en un parámetro ref. Use ambos atributos In y Out, o bien ninguno.

Un método de interfaz tiene un parámetro que usa ref con el atributo Out solamente. Un parámetro ref que usa el atributo Out también debe usar el atributo In .

El ejemplo siguiente genera la advertencia 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()  
   {  
   }  
}