views:

93

answers:

1

Possible Duplicates:
How to reference an indexer member of a class in C# comments
Static Indexers?


As it stands, I have to write my code like this

internal class ReportMap {

    static internal ReportMap Instance {
        get { return reportMap; }
    }

    internal Type this[char c] {
        get { return data[c]; }
    }

    // private parts
    static Dictionary<char, Type> data =
        new Dictionary<char, Type>();

    ReportMap() {
        data.Add('S', typeof(StatusReport));
        data.Add('Q', typeof(QualityReport));
    }

    static ReportMap reportMap = new ReportMap();
}

and to access an index:

Type t = ReportMap.Instance[aChar]; // eww

Is there a specific reason this ability was left out of the language? In particular, would it be considered bad design? There is another question on this already posted, but I unfortunately do not have enough rep to comment.

+1  A: 

That's a good dupe reference there. Specifically, check out the answer :-) http://stackoverflow.com/questions/401232/static-indexers/401275#401275

Joel Martinez