views:

93

answers:

2

When I press Ctrl+Left mouse button or F12 on a variable I get to the declaration of the variable.

Is there a shortcut like this to get to the class definition of the variable's type? So when I have a variable string functionCode I'd like to click functionCode anywhere in the program and get straight to the object browser showing me the string class.

Of course, this is most useful for self-defined classes and member variables. Sometimes I do not see the type of a member in a method at all - everywhere just var. To get to a class definition I have to go to the variable definition and from there to the class definition.

OK, this is all about saving one click ... but I am lazy ... is it possible?

PS: ReSharper solutions are welcome, too.

+1  A: 

The best way is by use of a mix between the code page and the Code Definition Window (Ctrl+W,D).

You can click on the item in code and view it in the Code Definition Window, then click on the base class in the code definition window and by using F12 it will take your code page to the base class definition.

ChrisBD
I did not use the Code Definition Window before - can it be automatically synchronized to the normal Code Window?
tanascius
This isn't possible because you need to know what item to retrieve the definition for. It works for all items including methods.In effect it is the same functionality as F12, but instead it just needs a single mouse click on the item that you wish to view and also shows it in a different window so that you can still read your code without that horrible window swapping.
ChrisBD
Oh - if you switch code windows then it will automatically display the definition for whatever is under the cursor.
ChrisBD
I don't understand why this answer is useful. If you have to do it in two steps, surely you can just F12 on the variable and then F12 again on its type (which works even with 'var' by the way). I think the asker was specifically looking for a single-step solution.
Timwi
When the code definition window is open then no key presses are needed for the immediate definition of the variable. You just place the cursor on the variable in the code and the definition automatically appears in the code definition window. You only need further key presses if you need to progress further in the class hiearchy.Another point is that it does not switch you away from your code window.
ChrisBD
A: 

I just realized that is is possible to click Ctrl+Left mouse button or to press F12 on the var-keyword, too ...

tanascius
I just learned the <kbd> tag :)
Peter
Please don't submit comments like this as an answer.
Timwi
@Timwi I consider this to be an answer - since I asked the question I am even sure that this discovery helped me ... :)
tanascius