Frage

I work with a codebase where several classes implement an indexer:

public double this[int i, int j]
{
    get { return ...; }
    set { ...; }
}

When I stumble over code like foo[1,2] = 3 in visual Studio 2008, I frequently want to
right-click / "go to definition", i.e. show the above definition in the visual studio editor window.

For normal properties or methods this works without problems:
foo.bar = 3, right-click / "go to definition" takes me to the source code for foo.bar.
For overloaded + or == this works as well.
However with the indexer this does not seem to work. Is there any way to accomplish this?

(I cannot even search for the string "this[" in the appropriate source file, since the same syntax may be used throughout the class to access the indexer. I always have to scroll trough all the methods and properties in the dropdown list for this file)

War es hilfreich?

Lösung

This doesn't really help with 2008 of course, but in 2010 and 2012 they have "fixed" this with the Navigate To command (ctrl+, in the C# keyboard layout). Where you can enter "this" to show a list of indexers in the current solution where you can double-click the one you want to navigate to.

+1 for Resharper which seems to work fine with pressing F12 when you caret is within an indexer usage.

Andere Tipps

You can install Resharper who give you this functionality, Tool Box productivity don't give this functionality

Your best bet will probably be to go to the definition of foo and see what that class is indexing.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top