Getting Started with .NET

Your journey into the world of .NET development begins here.

Welcome to .NET!

.NET is a free, cross-platform, open-source framework for building many different types of applications. With .NET, you can:

  • Build web apps and services with ASP.NET Core.
  • Create desktop apps for Windows, macOS, and Linux with WPF, Windows Forms, and .NET MAUI.
  • Develop mobile apps for iOS and Android with .NET MAUI.
  • Build games with Unity.
  • Work with IoT devices and machine learning.

This guide will help you set up your development environment and build your first .NET application.

Step 1: Install the .NET SDK

The .NET SDK (Software Development Kit) is essential for building .NET applications. It includes the .NET runtime, the SDK, and the dotnet command-line interface (CLI).

Choose your operating system:

Windows macOS Linux

Follow the installation instructions for your platform. Once installed, you can verify it by opening a terminal or command prompt and running:

dotnet --version

You should see the installed .NET SDK version printed.

Step 2: Choose Your Development Environment

While you can use any text editor and the dotnet CLI, an Integrated Development Environment (IDE) makes development much easier.

  • Visual Studio: The most comprehensive IDE for .NET development, available on Windows and Mac. Download Visual Studio
  • Visual Studio Code: A lightweight, free, and open-source code editor with excellent C# and .NET support via extensions. Download VS Code
  • JetBrains Rider: A powerful, cross-platform .NET IDE from JetBrains. Learn more about Rider

For beginners, Visual Studio Code is a great place to start due to its flexibility and free access.

Step 3: Create Your First Application

Let's create a simple "Hello, World!" console application. Open your terminal or command prompt, navigate to a directory where you want to create your project, and run the following commands:

dotnet new console -o MyFirstApp
cd MyFirstApp

This creates a new console application project named MyFirstApp in a new directory and then navigates you into that directory.

Now, open the Program.cs file in your chosen IDE. You'll see code similar to this:

// Program.cs
using System;

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

To run your application, go back to your terminal (make sure you're in the MyFirstApp directory) and execute:

dotnet run

You should see the output:

Hello, World!

What's Next?

Congratulations! You've successfully set up your .NET environment and created your first application.

Here are some resources to continue your learning: