10 Visual Studio Tools You May Not Know AboutThere are hundreds of Visual Studio Tools for the developer. Here are some of the tools which most developers don't even know about!

Several Visual Studio tools often go unnoticed but can significantly enhance productivity. These include Live Share for collaborative coding sessions, IntelliCode for AI-assisted coding suggestions, and CodeLens for real-time code metrics and insights. While these tools might not be widely used, integrating them into your workflow can streamline development and boost efficiency.
Encapsulate Field
As a good programming practice guideline, all public fields in a class should be encapsulated. This is easy to do, thanks to the Refactor tools. Declare a private field, Right click > Refactor > Encapsulate Field
. This will automatically create a public property for you.
You will get the option to name the property, and the tool will update all references to the private field for you. You can also preview any changes before they are made.
Before:
private string _name;
After:
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
Extract Method
Find yourself rewriting duplicate code or copying and pasting the code from one class to another. Extracting that code into a method can save a lot of work. The Extract Method tool can create a process from the currently selected text.
Highlight a block of text, Right click > Refactor > Extract Method
. The selected text will then be converted into a method with a name you provide.
static void Main(string[] args)
{
const int number = 45;
string name = number.ToString() + " number text";
Console.WriteLine(name);
}
Becomes:
static void Main(string[] args)
{
const int number = 45;
string name = MakeNumberText(int number)
Console.WriteLine(name);
}
private string MakeNumberText(int number)
{
string name = number.ToString() + " number text";
return name;
}
Ok, so it's just a simple one-line example, but you get the idea.
Surround With
Adding a try... catch... finally block to your code is as easy as selecting the code, right-clicking and choosing "Surround With...". This will pop up a shortlist where you can select "tryf" for a "try catch finally" or try for a "try-catch" Your selected code is now inside a try block, and the catch block is now waiting for something to do!
You can also use the "surround with" tool, which will add loops, namespaces, classes while using and many more blocks.
Easy!
Generate Method Stub
You are busy bashing out a new block of code and need to call an external method but don't want to stop. You already know the method name and its parameters, so call it as you normally would.
string test = "this is a test: ";
for (int itemNo=0; itemNo<=10; itemNo++)
{
Console.WriteLine(test + itemNo);
float price = GetItemPrice(itemNo)
Console.WriteLine(itemNo + " costs " + price);
}
Nothing wrong with this except that the GetItemPrice method does not exist. Rather than typing out a new method declaration, generate a method stub and let the IDE do the work.
Right-click the new method and select "Generate Method Stub", and the IDE will automatically insert the method for you:
private static float GetItemPrice(int itemNo)
{
throw new Exception("The method or operation is not implemented.");
}
The exception will prevent you from forgetting to complete the method when you come to run the project.
This is particularly useful when writing my business logic and UI layers. When writing my UI code, I will call the logic layer:
int price = BusinessLogic.Products.GetItemPrice(itemNo);
Use the generate method stub and carry on working and finish the UI code - the code still builds and will compile normally. I can then use the go-to definition shortcut to do the actual work in the GetItemPrice method later.
Go To Definition
So you are buried deep into somebody else's code, trying to figure out what everything is. You find a variable but don't know where it is declared. Or maybe there is a method call, and you want to look into the code, or you want to look at a class.
You can right-click on any variable, class, method, or property and select "Go To Definition", and the code editor will jump to the line of code where that object is declared. VERY useful in large projects with many files. You can use the "Navigate Backwards" button to return to where you were.
You can also use the Code Definition Window to see a read-only version of the relevant lines of code in a separate code pane.
Find All References
Another useful tool in a large project is the Find All References tool. This will allow you to find every line of code that uses the selected variable, method, or class. Useful if you decide to remove or replace a class with a new version and need to see where the old one is used.
How is it different to find the text? Well, this tool will only look at the object's scope, so if you are looking for a class member called Name, it will only find references to this property in this class, not any other classes or properties with the same name. The tool will also not search within comments or strings, which the find tool will.
Debug Exceptions Window
Tired of trying to remember a specific exception namespace or class or trying to find a relevant exception to throw? You can use the Debug > Exceptions window
Ctrl + Alt + E to see a structured list of all the default system exceptions. You can drill down into the Common Runtime exceptions and the System to view all the exception classes.
Comment/Uncomment Sections
Using the comment section tool, you can quickly comment out large quantities of text. This can be accessed from the toolbar or the Edit > Advanced
menu. You can also use the Ctrl + K and Ctrl + C shortcuts. To uncomment multiple lines, you can use Ctrl + K or Ctrl + U.
You can use the multi-line comment as well if you wish...
Locate Matching Brackets
A little keyboard shortcut Ctrl + ] will cause the caret to jump between matching brackets or parentheses and can be invaluable for locating missing or additional brackets.
Vertical Selection
You can use the mouse to select letters and lines horizontally, but can you use the Alt key to choose columns? This is great if you must clear a load of characters or text in a vertical column rather than rows. Press and hold down the Alt key, then click and drag with the mouse.
Do you have any tips or shortcuts to share with our readers? Please let us know by leaving a comment on this article.