Getting Started with .NET Core

Welcome to the .NET Core getting started guide. This section will walk you through the essential steps to begin developing applications with .NET Core.

1. Prerequisites

Before you begin, ensure you have the following installed on your system:

2. Creating Your First .NET Core Application

Once the SDK is installed, you can create your first application using the command line.

a. Open your terminal or command prompt.

Navigate to the directory where you want to create your project.

b. Create a new console application.

Run the following command:

dotnet new console -o MyFirstApp

This command does the following:

c. Navigate into your project directory.

cd MyFirstApp

d. Run your application.

Execute the following command to build and run your application:

dotnet run

You should see the following output:

Hello, World!

3. Understanding the Project Structure

Your new console application will have a simple structure:

The Program.cs file typically contains the following code:

using System;

        namespace MyFirstApp
        {
            class Program
            {
                static void Main(string[] args)
                {
                    Console.WriteLine("Hello, World!");
                }
            }
        }

Note: The dotnet run command automatically builds your project if necessary before running it. You can also use dotnet build to only build the project.

4. Exploring Other Project Types

.NET Core supports a variety of application types. You can create them using the dotnet new command:

You can see a full list of available project templates by running: dotnet new --list

Key takeaway: The dotnet new command is your primary tool for scaffolding new .NET Core projects of various types.

Next Steps

Now that you've created your first .NET Core application, you can explore more advanced topics: