Easily Find Classes, Methods, and Variables

I02B0065 There is a bit of a “trick” that I use routinely in Visual Studio to help me find the definition of Classes, Methods, and Variables in my solution regardless.

This “trick” works in both CSharp and in VB.NET and, if you don’t know it already, will save you a ton of time.

If you want to know the type of a variable, obviously all you need to do is hover your mouse over it, but if you want to know the definition of the class that your variable is defined as, what do you do?

My bet is that many of you are searching for the class in the solution explorer.

Instead, you can do this:

  • Right click on the variable name.
  • Select “Go To Definition”  from the resulting context menu.
  • This will place you on the variable declaration line.
  • Right-click the class name on the variable declaration line.
  • Select “Go To Definition” from the resulting context menu (no, this is not a type-o.  Do it a second time).
  • You will now be at the class.

This works even if the method is in the .NET library and you don’t have the code for it.  It will simply bring up as much of the class definition as it can reflect.  That is, you’ll see the class name, methods, and properties, but you won’t see the code that actually makes it all work.

 

Other post in Did you know

Related Post

  • Self Executing Anonymous FunctionSelf Executing Anonymous Function Not because it is all that new, but because it took me a while to find it, here’s how to create a self executing anonymous function using CSharp, just like you can do in JavaScript. ((Func<...
  • Finding a CSS Class DefinitionFinding a CSS Class Definition A couple of weeks ago I pointed out that you could easily find the definition of a property, method, variable, or class by right-clicking the item and selecting, "Go To Definition" from the contex...
  • Renaming Properties, Methods and VariablesRenaming Properties, Methods and Variables Have you ever written some code and named something one thing only to realize that it should be named something else? If you haven't you haven't been programming for very long.  Maybe you start...
  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it wrong, which...
  • Readonly variables in CSharp? Really?!Readonly variables in CSharp? Really?! I'm sure most of you are familiar with the keyword "const," which allows you to declare a variable and give it a value and assures that no other code will change the value. const int v = 23; p...