Errore del compilatore CS0620

Aggiornamento: novembre 2007

Messaggio di errore

Gli indicizzatori non possono avere tipi void
Indexers cannot have void type

Il tipo restituito di un indicizzatore non può essere void. Un indicizzatore deve restituire un valore.

Il seguente codice di esempio genera l'errore CS0620:

// CS0620.cs
class MyClass
{
   public static void Main()
   {
      MyClass test = new MyClass();
      System.Console.WriteLine(test[2]);
   }

   void this [int intI]   // CS0620, return type cannot be void
   {
      get
      {
         // will need to return some value
      }
   }
}

Vedere anche

Riferimenti

void (Riferimenti per C#)