Working with C#

The C# support in VS Code is optimized for cross-platform .NET development (DNX) (see working with ASP.NET 5 and VS Code for another relevant article). Our focus with VS Code is to be a great editor for cross-platform C# development. For instance many Unity game developers have been enjoying using VS Code in place of the MonoDevelop IDE. The will pick up errors as you type.

We support debugging of C# apps cross-platform via Mono (see Mono Debugging).

Due to this focus many standard C# project types are not recognized by VS Code. An example of a non-supported project type is an ASP.NET MVC Application. In these cases if you simply want to have a lightweight tool to edit a file - VS Code has you covered. If you want the best possible experience for those projects and development on Windows in general, we recommend you use Visual Studio Community.

Roslyn and OmniSharp

Visual Studio Code uses the power of Roslyn and OmniSharp to offer an enhanced C# experience. We offer support for both: - DNX projects - MSBuild projects

On startup the best matching projects are loaded automatically but you can also choose your projects manually. The status bar will show what projects have been loaded and also allows you to select a different set of projects. To do so, click on the status bar projects item and select Change projects…. In the image below a single project has been picked up:

Select Project

The available options include:

  • Selecting a project.json file will open a DNX-project and VS Code will load that project plus the referenced projects.
  • Selecting a *.sln file opens a MSBuild-project. It will load the referenced *.csproj projects and sibling or descendant project.json files but no other project files that are referenced from the solution file.
  • Selecting a folder will make VS Code scan for *.sln and project.json files and VS Code will attempt to load them all.

Once the project is loaded the enhanced experiences light up...

Editing Evolved

There is a lot to discover with C# and the editor, such as format on type, IntelliSense, the rename-refactoring, etc.

Right Click Menu

For a full description of our editing features go to the Editing Evolved documentation.

Here are a few highlights...


IntelliSense just works hit kb(editor.action.triggerSuggest) at any time to get context specific suggestions.


Snippets for C#

We have several built-in snippets included in VS Code that will come up as you type or you can press kb(editor.action.triggerSuggest) (Trigger Suggest) and we will give you a context specific list of suggestions.


Tip: You can add in your own User Defined Snippets for C#. Take a look at User Defined Snippets to find out how.

Search for Symbols

There are also features outside the editor. One is the ability to search for symbols from wherever you are. Hit kb(workbench.action.showAllSymbols), start typing, and see a list of matching C# symbols. Select one and you’ll be taken straight to its code location.


Code Lens

Another cool feature is the ability to see an indication of the number of references to a method directly above the method. Click on the reference info to see the references in the peek view. This reference information is updated as you type.

Note: Methods defined in object, such as equals and hashCode do not get reference information due to performance reasons.

Code Lens

Tip: You can turn off references information in the User Settings under the property editor.referenceInfos.

Find References/Peek Definition

You can click on the references of an object to find the locations of its use in place without losing context. This same experience works in reverse where you can Peek the definition of an object and see it inline without leaving your location.


Quick Fixes / Suggestions

There are some basic quick fixes supported in VS Code. You will see a lightbulb and clicking on it will provide you with a simple list of fixes/suggestions.

Quick fix

Next Steps

Read on to find out about:

Common Questions

Q: My Project won't load.

A: VS Code only supports a limited set of project types (primarily ASP.NET 5). For full .NET project support, we suggest you use Visual Studio Community.

Q: IntelliSense is not working.

A: This is typically as a result of the current project type not being supported. You can see an indication in the OmniSharp flame in the bottom left hand side of the status bar.

Q: How do I build/run my project?

A: VS Code supports tasks for build and natively understand the output of MSBuild, CSC, XBuild. Find out more in the Tasks documentation.