Compartir a través de


Error del compilador CS0662

Actualización: noviembre 2007

Mensaje de error

'método' no puede especificar sólo el atributo Out en un parámetro ref. Utilice los atributos In y Out, o bien no utilice ninguno.
'method' cannot specify only Out attribute on a ref parameter. Use both In and Out attributes, or neither.

Un método de interfaz tiene un parámetro que utiliza ref con sólo el atributo Out. Un parámetro ref que utilice el atributo Out debe usar también el atributo In.

El código siguiente genera el error 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()
   {
   }
}