Getting Started with .NET
Welcome to .NET!
.NET is a free, cross-platform, open-source developer platform for building many different types of applications. With .NET, you can use C#, F#, or Visual Basic to create applications that run on Windows, macOS, Linux, iOS, Android, and more.
This guide will help you set up your development environment and build your first .NET application.
Prerequisites
Before you begin, ensure you have the following installed:
- .NET SDK: The .NET Software Development Kit (SDK) includes the .NET runtime, libraries, and tools needed to build and run .NET applications. Download it from the official dotnet.microsoft.com/download page.
- Code Editor: A text editor or Integrated Development Environment (IDE) for writing code. Popular choices include:
- Visual Studio Code (free, cross-platform)
- Visual Studio (Windows, macOS)
- JetBrains Rider (cross-platform)
Step 1: Install the .NET SDK
Follow the installation instructions for your operating system from the official .NET website. Once installed, you can verify by opening a terminal or command prompt and typing:
dotnet --version
You should see the installed .NET SDK version displayed.
Step 2: Create Your First Application
We'll 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 HelloWorldApp
cd HelloWorldApp
This command creates a new console application project named HelloWorldApp
in a new directory. The cd HelloWorldApp
command navigates you into that directory.
Step 3: Write Your Code
Open the Program.cs
file in your code editor. It should contain code similar to this:
using System;
namespace HelloWorldApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
The Console.WriteLine("Hello, World!");
line is responsible for printing the message to the console.
Step 4: Run Your Application
In your terminal, while inside the HelloWorldApp
directory, run the following command:
dotnet run
You should see the output:
Hello, World!
Congratulations!
You've successfully created and run your first .NET application. This is just the beginning of your journey with .NET. Explore the vast possibilities and build amazing applications!