JoelFan
JoelFan

Reputation: 38704

Find out what class a method belongs to (in Visual Studio or Resharper)

If I'm looking at a method definition in Visual Studio (with Resharper) is there an easy way to find out what class it belongs to? (As of now, I've resorted to a text search in the "up" direction for the string "class".)

Upvotes: 0

Views: 197

Answers (5)

Jura Gorohovsky
Jura Gorohovsky

Reputation: 10138

Aside from using ReSharper's File Structure and/or Go to Containing Declaration - options mentioned previously - there's also a tiny feature in ReSharper called Quick Documentation that in my view is better suited for this kind of task since it shows you method info in-place, without forcing you to navigate anywhere from the method you're on. Ctrl+Q, Esc, and you're done. It works on all kinds of symbols (not limited to methods), both on declarations and on usages.

Upvotes: 1

brgerner
brgerner

Reputation: 4371

The best (direct) way specific to your question is PHeiberg's answer.
But if you ask this question I guess you don't know the File Structure window that can be enabled by ReSharper->Windows->File Structure or by shortcut Ctrl+Alt+F.

enter image description here

With that window you see always where you are in your file.

Upvotes: 1

AakashM
AakashM

Reputation: 63340

You have files with more than one class in? That makes ponies sad...

Anyway, to actually answer, can't you just look at the navigation bar?

enter image description here

Upvotes: 1

PHeiberg
PHeiberg

Reputation: 29811

The Resharper command Go to containing declaration (ctrl + [) should do the trick

Edit: Or if you have the navigation bar at the top of the code window enabled, that should display the type name. But I have that turned off, since I use keyboard navigation and the bar itself slows down Visual Studio.

Upvotes: 4

Dominic
Dominic

Reputation: 31

For VS, right click on the function and select 'Go To Declaration'. (Ctrl + F12)

Upvotes: 0

Related Questions