Share via


Erreur du compilateur CS0662

Mise à jour : novembre 2007

Message d'erreur

'méthode' ne peut pas spécifier uniquement un attribut Out sur un paramètre ref. Utilisez les deux attributs In et Out ou aucun des deux.
'method' cannot specify only Out attribute on a ref parameter. Use both In and Out attributes, or neither.

Une méthode d'interface a un paramètre qui utilise ref avec uniquement l'attribut Out. Un paramètre ref qui utilise l'attribut Out doit également utiliser l'attribut InAttribute.

L'exemple suivant génère l'erreur 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()
   {
   }
}