Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IndexerName attribute on abstract classes

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.

like image 786
Steven Suryana Avatar asked Oct 11 '22 07:10

Steven Suryana


1 Answers

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.

like image 178
Jalal Said Avatar answered Oct 18 '22 10:10

Jalal Said