Visual Studio Console Application

Visual Studio Code is a free code editor developed by Microsoft for Windows, Linux, and macOS. We create the C# Console application in Vs code with the help of.NET Core. Visual Studio Code (Vs Code) is optimized for cross-platform.NET Core development. This project template can be used as a basic starting point for creating a C# DNX console application. It can be used to bootstrap the development of a basic DNX console application. You will be apple to run and debug the DNX Console Application form Visual Studio 2015. At this point in time it uses the DNX rc1-final, but I wil.

A set of project templates for C++/CX, C++/WinRT and C#, for building Universal Console Apps.

The following notes apply to all releases:

  • The C# template will only work with Visual Studio 2017 Version 15.7 or later. Note that with the C# template, you might get the error message 'Output type 'Console Application' is not supported by one or more of the project's targets'. You can ignore this message, as it does not prevent the project from building correctly.

  • The C# console apps are only supported on Windows 10 from version 10.0.17134.0 of the platform. You should therefore specify a version >= 10.0.17134.0 for the TargetPlatformMinVersion when you create your project.

  • For the C++/WinRT flavor, note that more strict language conformance means that if you target 10.0.17134.0 of the platform you will need to remove the /permissive- flag from the C++ compiler options. Alternatively, you can target 10.0.17663.0 or later. This is described more fully here: https://kennykerr.ca/2018/08/15/compilers-and-conformance/.

Version 1.9 adds support for Visual Studio 2019, which is in preview as of this release.

Visual Studio Console Application

Version 1.8 removes the message about installing a version of Microsoft.NETCore.UniversalWindowsPlatform, and the related delay in generating the project.

Version 1.7 reverts the fix in 1.6 - because the correct fix is in Visual Studio itself. That fix is available from Visual Studio 2017 Version 15.9 Preview 3. The updated project template for C# sets the .csproj back to the v1.5 state, with these 2 lines:Exetrue

...instead of the one line: AppContainerExe

Version 1.6 corrects a bug in the C# template where the final package would fail the Windows App Cert Kit (WACK) tests. If you want to retro-fit the fix to an existing project, you can edit your .csproj file manually, and replace these 2 lines:Exetrue

...with this one line instead:AppContainerExe

New projects created with the v1.6 template will already have this fix. This only applies to C# not to C++.

Application

Version 1.5 adds support for C#.

Version 1.4 corrects a couple of bugs in the previous version, as detailed below. These bugs do not prevent the app from building and executing, but they do prevent correct packaging and store publication. If you have already created projects using the old templates, you can apply the fixes by making the same changes in the .vcxproj and package.appxmanifest files manually:

For both C++/CX and C++/WinRT: In the .vcxproj file, removed the .NET Native declarations – both the target framework declarations at the top of the file:.NETCorev5.0

...and also multiple instances of the following:v141true

In the package.appxmanifest file, added iot2 to the ignorable XML namespaces:IgnorableNamespaces='uap mp uap5 iot2 desktop4'>

Version 1.1 is the first release, and includes project templates for C++/CX and C++/WinRT.

-->

In this 5-10 minute introduction to the Visual Studio integrated development environment (IDE), you'll create a simple Visual Basic application that runs on the console.

If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

Visual Studio Console Application

If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

If you haven't already installed Visual Studio 2022 Preview, go to the Visual Studio 2022 Preview downloads page to install it for free.

Create a project

First, you'll create a Visual Basic application project. The project type comes with all the template files you'll need, before you've even added anything!

  1. Open Visual Studio 2017.

  2. From the top menu bar, choose File > New > Project.

  3. In the New Project dialog box in the left pane, expand Visual Basic, and then choose .NET Core. In the middle pane, choose Console App (.NET Core). Then name the project HelloWorld.

    If you don't see the Console App (.NET Core) project template, click the Open Visual Studio Installer link in the left pane of the New Project dialog box.

    The Visual Studio Installer launches. Choose the .NET Core cross-platform development workload, and then choose Modify.

Note

Some of the screenshots in this Quickstart use the dark theme. If you aren't using the dark theme but would like to, see the Personalize the Visual Studio IDE and Editor page to learn how.

  1. Open Visual Studio.

  2. On the start window, choose Create a new project.

  3. In the Create a new project window, choose Visual Basic from the Language list. Next, choose Windows from the Platform list and Console from the project types list.

    After you apply the language, platform, and project type filters, choose the Console Application template, and then choose Next.

    Note

    If you do not see the Console Application template, you can install it from the Create a new project window. In the Not finding what you're looking for? message, choose the Install more tools and features link.

    Then, in the Visual Studio Installer, choose the .NET Core cross-platform development workload.

    After that, choose the Modify button in the Visual Studio Installer. You might be prompted to save your work; if so, do so. Next, choose Continue to install the workload. Then, return to step 2 in this 'Create a project' procedure.

  4. In the Configure your new project window, type or enter WhatIsYourName in the Project name box. Then, choose Next.

  5. In the Additional information window, .NET Core 3.1 should already be selected for your target framework. If not, select .NET Core 3.1. Then, choose Create.

    Visual Studio opens your new project.

Create the application

After you select your Visual Basic project template and name your project, Visual Studio creates a simple 'Hello World' application for you. It calls the WriteLine method to display the literal string 'Hello World!' in the console window.

Visual

If you click the HelloWorld button in the IDE, you can run the program in Debug mode.

Visual Studio Console Application Exe

When you do this, the console window is visible for only a moment before it closes. This happens because the Main method terminates after its single statement executes, and so the application ends.

Add some code

Let's add some code to pause the application and then ask for user input.

  1. Add the following code immediately after the call to the WriteLine method:

    This pauses the program until you press a key.

  2. On the menu bar, select Build > Build Solution.

    This compiles your program into an intermediate language (IL) that's converted into binary code by a just-in-time (JIT) compiler.

Visual Studio Debug Console Application

Run the application

  1. Click the HelloWorld button on the toolbar.

  2. Press any key to close the console window.

Next steps

Visual Studio What Is A Console Application

Congratulations on completing this Quickstart! We hope you learned a little bit about Visual Basic and the Visual Studio IDE. To learn more, continue with the following tutorial.