Using the dotnet CLI
Step 1: Create a new console application
- Open a terminal and navigate to your desired project directory
- Create a new console application:
dotnet new console -n MyFirstConsoleApp
- Navigate into the new project directory:
cd MyFirstConsoleApp
Step 2: Explore the project structure
- Open the folder in Visual Studio Code.
- Install the C# Dev Kit extension if not already installed
- Examine the generated files, particularly
Program.cs
andMyFirstConsoleApp.csproj
.
Step 3: Build and run the console application
- Build the application:
dotnet build
- Run the application:
dotnet run