Errore del compilatore CS0668
Due indicizzatori hanno nomi diversi. L'attributo IndexerName deve essere usato con lo stesso nome in ogni indicizzatore all'interno di un tipo.
I valori passati all'attributo IndexerName devono essere identici per tutti gli indicizzatori di un tipo. Per altre informazioni sull'attributo IndexerName , vedere Classe IndexerNameAttribute.
L'esempio seguente genera l'errore 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()
{
}
}
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: