Errore del compilatore CS0662

Aggiornamento: novembre 2007

Messaggio di errore

'metodo' non può specificare solo l'attributo Out in un parametro ref. Utilizzare entrambi gli attributi In e Out o nessuno dei due.
'method' cannot specify only Out attribute on a ref parameter. Use both In and Out attributes, or neither.

Un metodo di interfaccia include un parametro che utilizza ref solo con l'attributo Out. Un parametro ref che utilizza l'attributo Out deve utilizzare anche l'attributo In.

Il seguente codice di esempio genera l'errore 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()
   {
   }
}