Číst v angličtině

Sdílet prostřednictvím


Chyba kompilátoru CS0609

Nelze nastavit atribut IndexerName u přepsání označeného indexerem.

Atribut name (IndexerNameAttribute) nelze použít u indexované vlastnosti, která je přepsána. Další informace najdete v tématu Indexery.

Následující ukázka vygeneruje CS0609:

// CS0609.cs
using System;
using System.Runtime.CompilerServices;

public class idx
{
   public virtual int this[int iPropIndex]
   {
      get
      {
         return 0;
      }
      set
      {
      }
   }
}

public class MonthDays : idx
{
   [IndexerName("MonthInfoIndexer")]   // CS0609, delete to resolve this CS0609
   public override int this[int iPropIndex]
   {
      get
      {
         return 0;
      }
      set
      {
      }
   }
}

public class test
{
   public static void Main(string[] args)
   {
   }
}

Poznámka

Tato chyba kompilátoru se už v Roslynu nepoužívá. Předchozí kód by se měl úspěšně zkompilovat.