Loading...

Visual Studio / VS Code Tips for C#

Learn Visual Studio and VS Code tips for C# to improve productivity with shortcuts, extensions, and efficient workflows.

Visual Studio and Visual Studio Code (VS Code) are two of the most powerful and widely used IDEs among C# developers. These tools not only facilitate writing code but also simplify debugging, auto-completion, testing, version control, and refactoring. Below is a compilation of the most useful tips, shortcuts, and settings to enhance productivity in these environments.


Visual Studio – General Tips


Debugging Shortcuts

Visual Studio has powerful debugging capabilities; using the right shortcuts can significantly reduce debugging time.


Code Navigation

These features make navigating large projects much easier. Especially Ctrl + , is very handy for searching both methods and files.


Refactoring (Code Restructuring)

Visual Studio supports Refactoring operations to improve code quality.


Visual Studio Code – Developer Tips

VS Code is a lightweight yet highly extensible editor. For C# support, use the C# Dev Kit or OmniSharp extensions.


VS Code Extensions

The power of VS Code lies in its extensibility. The following extensions are recommended to boost productivity in C# projects:


Themes and Editor Customization

Choosing the right theme helps reduce eye strain during long coding sessions. In VS Code, you can change the theme with Ctrl + K + T.

Recommended fonts: Cascadia Code or JetBrains Mono – both provide ligature support for a clean look.


Git and Version Control

Both Visual Studio and VS Code provide built-in Git integration. In VS Code, access it via the Source Control icon (branch icon) or Ctrl + Shift + G.

In Visual Studio, use the “Team Explorer” panel to easily perform commit, push, or merge operations.


Live Code Analysis (Code Analysis & Linter)

You can enable Roslyn-based analyzers to detect issues before compiling.


[*.cs]
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1303.severity = warning

This file defines your coding standards. Both VS Code and Visual Studio automatically apply these rules.


Performance and Memory Profilers

In Visual Studio, the Diagnostics Tools window (Ctrl + Alt + F2) allows you to analyze CPU usage, memory consumption, and GC events. This tool is particularly useful for identifying performance bottlenecks.


// Access from the menu:
// Debug → Performance Profiler → Memory Usage / CPU Usage

Real-World Example: Using VS Code + .NET CLI

The following example demonstrates how to create and debug a simple C# project using only VS Code and the .NET CLI.


// Create a new project
dotnet new console -n SampleProject
cd SampleProject

// Open in VS Code
code .

// Debug configuration will be generated automatically (launch.json)

// Program.cs
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, VS Code Debugging!");
    }
}

Press F5 to start debugging. The OmniSharp debugger will activate, and the program will run. Breakpoints, Watch panel, and Call Stack tools are available in VS Code just like in Visual Studio.


Best Practices


TL;DR

  • Visual Studio – A full-featured IDE with deep debugging, profiling, and refactoring tools.
  • VS Code – Lightweight, fast, and extensible editor.
  • Shortcuts like Ctrl + K + D, F12, and Ctrl + , boost productivity.
  • Use the Ctrl + . menu for refactoring actions.
  • OmniSharp / C# Dev Kit are essential for C# in VS Code.
  • Use “Diagnostics Tools” for performance analysis.
  • Use .editorconfig and Roslyn analyzers to maintain code quality.

Related Articles