Working With Visual Studio Code

C# From Scratch Part 2.3

Ken Bourke
Dec 16, 2020 · 4 min read

Work with .NET projects is much easier in a full-featured editor like Visual Studio Code.

Launch Visual Studio Code

Navigate back to the Gradebook folder in the Command Prompt using the command ‘cd ..’. This tells the Command Prompt that we want to go up one level in the file system.

In the Gradebook directory, launch Visual Studio Code using the ‘code .’ command. This command will launch Visual Studio Code provided that you added Visual Studio Code to your PATH during the installation.

Visual Studio Code launches with the Gradebook folder open in the Explorer pane.

Set Up Visual Studio Code

Visual Studio Code is a modular, flexible editor — it’s not designed to work with only one programming language. Visual Studio Code users can install extensions to make it easier to work with specific languages in Visual Studio Code.

Open the Extensions window in Visual Studio Code and search for C#.

The first result is C# for Visual Studio Code by Microsoft. This extension makes it easier to work with C# in Visual Studio Code. According to the description, C# for Visual Studio Code provides us with:

  • Lightweight development tools for .NET Core.
  • Great C# editing support, including Syntax Highlighting, IntelliSense, Go to Definition, Find All References, etc.
  • Debugging support for .NET Core (CoreCLR). NOTE: Mono debugging is not supported. Desktop CLR debugging has limited support.
  • Support for project.json and csproj projects on Windows, macOS and Linux.

Click ‘Install’ to install the extension to Visual Studio Code.

The Output window at the bottom of the screen shows the installation progress. When the installation is finished, you should see the message ‘Finished’ here.

Shortly after installing the extension, Visual Studio Code will warn you that “Required assets to build and debug are missing from ‘Gradebook’”. Click Yes to download the required assets.

These assets make it easier to run and debug C# applications in Visual Studio Code.

Now Visual Studio Code is set up to work with C# projects.

Editing the Source Code

Open the Explorer window in Visual Studio Code. Expand the src folder and open Program.cs by clicking on the file.

Intuitively, we can see that the output of the application, the message “Hello World!”, is coming from line 9 of Program.cs.

Modify the string (the sequence of characters between the double quotes) to change the output of the application.

Running the Application with Visual Studio Code

Save your changes with CTRL + S and run the application by clicking Run > Run Without Debugging or by pressing CTRL + F5 on your keyboard.

Visual Studio Code runs the application for you and the output of the application is printed to the Debug Console at the bottom of the window.

You can see that the changes we made to the source code have been applied to the application and the output is modified.

What’s Next?

In this part of the series, we learned how to work with Visual Studio Code. Specifically, we learned how to launch Visual Studio Code from the Command Prompt window, how to install extensions, how to modify source code, and how to run the application

In the next part of the series, we’ll dive into the contents of Program.cs to get a deeper understanding of how our program works. After that, we can work on making the application interactive. You can find the next part of the series here.

Missed a part of the series? You can find an overview of the series and links to all previous parts on the index page.

The Startup

Get smarter at building your thing. Join The Startup’s +724K followers.

Ken Bourke

Written by

Automation Engineer, Technology Enthusiast, Freelance/Consulting. Official website: https://www.kb-controls.io/

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +724K followers.

Ken Bourke

Written by

Automation Engineer, Technology Enthusiast, Freelance/Consulting. Official website: https://www.kb-controls.io/

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +724K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store