diff --git a/docs/core/tutorials/with-visual-studio-code.md b/docs/core/tutorials/with-visual-studio-code.md index da93afe7d0cb5..98e004ac98689 100644 --- a/docs/core/tutorials/with-visual-studio-code.md +++ b/docs/core/tutorials/with-visual-studio-code.md @@ -3,7 +3,7 @@ title: Get started with C# and Visual Studio Code - C# Guide description: Learn how to create and debug your first .NET Core application in C# using Visual Studio Code. author: kendrahavens ms.author: mairaw -ms.date: 11/28/2018 +ms.date: 12/05/2018 --- # Get Started with C# and Visual Studio Code @@ -82,6 +82,50 @@ You can also watch a short video tutorial for further setup help on [Windows](ht > [!TIP] > For more information and troubleshooting tips on .NET Core debugging with OmniSharp in Visual Studio Code, see [Instructions for setting up the .NET Core debugger](https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger.md). +## Add a class + +1. To add a new class right-click in the VSCode Explorer and select **New File**. This adds a new file to the folder you have open in VSCode. +2. Name your file `Class1.cs`. You must save it with a `.cs` extension at the end for it to be recognized as a csharp file. +3. Add the code below to create your first class. Make sure to include the correct namespace so you can reference it from your `Program.cs` file. +``` csharp +using System; + +namespace HelloWorld +{ + public class Class1 + { + public string ReturnMessage() + { + return "Happy coding!"; + } + } +} +``` + +4. Call your new class from your main method in `Program.cs` by adding the code below. + +```csharp +using System; + +namespace HelloWorld +{ + class Program + { + static void Main(string[] args) + { + Class1 c1 = new Class1(); + Console.WriteLine($"Hello World! {c1.ReturnMessage()}"); + } + } +} +``` + +5. Save your changes and run your program again. The new message should appear with the appended string. +```console +> dotnet run +Hello World! Happy coding! +``` + ## FAQ ### I'm missing required assets to build and debug C# in Visual Studio Code. My debugger says "No Configuration."