I'm trying to rename my indexer property using IndexerName attribute on my abstract classes. But it still show compilation error The type 'XXX' already contains a definition for 'Item'.
Abstract class:
public abstract class MyAbstract
{
[IndexerName("Indexer")]
public abstract string this[string propertyName]
{
get;
}
}
Concrete class:
public class MyConcrete : MyAbstract
{
string item;
public string Item
{
get { return item; }
set { item = value; }
}
public override string this[string propertyName]
{
get { return propertyName; }
}
}
Compilation error:
The type 'MyConcrete' already contains a definition for 'Item'.
I've tried to put IndexerName on indexer override and it show error "Cannot set the IndexerName attribute on an indexer marked override"
How to use IndexerName on abstract classes ?
Thanks in advance.
The issue will be fixed if you just rename the Item
to something else, also consider checking this related issue on IndexerName
at here and here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With