Visual Studio: Find class I'm in

1.2k Views Asked by At

How do I determine what class the method I'm looking at belongs to?

public class class1 {
  ...
}
public class class2 {
  ... // many lines of code!
  public static bool TheMethodIWantToUse() {
    ...
  }
  ... // many more lines of code 
}
public class class3 {
  ...
}

Say that I have this file open in VisualStudio, and I've finally found TheMethodIWantToUse() by CTRL+F.

Is there any way that I can quickly find the name of the class that this is in -- class2 -- so I can actually use the method? (Assume there are so many lines that scrolling would be very tedious).

For example, if I can put my cursor just outside of the method and ask to go to the beginning of the current block, that would work well, though I don't know if there's a way to do that.

I am using VS 2015, and am working on a codebase that I did not myself write. I also have access to the ReSharper extension, and am willing to install additional ones that do not cost money.

1

There are 1 best solutions below

1
On BEST ANSWER

enter image description here

You can check the top of the bar to see which class/method..etc you are currently modifying.

To search for a certain class, you can use Ctrl + F or click on the class you are currently inside on that bar (meaning to click on 'ConsoleApplication3.test' on that bar above in my case) and the list of class will pop up. Click on your desired class and it will redirect you to the class you want to go to. [If it doesn't , just type something and you will 'fly' to that code or trying doing it again]

These works for method/functions too.