Compiler Error CS0668

Two indexers have different names; the IndexerName attribute must be used with the same name on every indexer within a type

The values passed to the IndexerName attribute must be the same for all indexers in a type. For more information on the IndexerName attribute, see IndexerNameAttribute Class.

The following sample generates CS0668:

// CS0668.cs  
using System;  
using System.Runtime.CompilerServices;  
  
class IndexerClass  
{  
   [IndexerName("IName1")]  
   public int this [int index]   // indexer declaration  
   {  
      get  
      {  
         return index;  
      }  
      set  
      {  
      }  
   }  
  
   [IndexerName("IName2")]  
   public int this [string s]    // CS0668, change IName2 to IName1  
   {  
      get  
      {  
         return int.Parse(s);  
      }  
      set  
      {  
      }  
   }  
  
   void Main()  
   {  
   }  
}