Getting Started with .NET
A complete guide to getting started with .NET and C# application development
Getting Started with .NET
.NET is an open-source development platform built by Microsoft. With .NET, you can build all kinds of applications: web, mobile, desktop, cloud, gaming, IoT, and more.
What is .NET?
.NET (pronounced “dot net”) is:
- A framework for building applications
- A runtime for running applications
- An ecosystem encompassing libraries, tools, and community
.NET Versions
| Version | Status | Notes |
|---|---|---|
| .NET 8 | LTS (Long Term Support) | Recommended for production |
| .NET 7 | Current | Shorter support window |
| .NET 6 | LTS | Supported until 2024 |
| .NET Framework 4.8 | Legacy | Windows only |
Recommendation: Use .NET 8 for new projects. It’s the latest LTS release with support through 2026.
Installing the .NET SDK
Windows
- Download the .NET SDK from dotnet.microsoft.com
- Run the installer
- Restart your terminal/command prompt
macOS
# Using Homebrew
brew install dotnet-sdk
# Or download from the official website
Linux (Ubuntu/Debian)
# Add the Microsoft repository
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
# Install the SDK
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0
Verify the Installation
# Check .NET version
dotnet --version
# View detailed information
dotnet --info
Your First Project
Let’s build a simple “Hello World” application.
1. Create a New Project
# Create the project folder
mkdir hello-dotnet
cd hello-dotnet
# Create a console project
dotnet new console
2. Project Structure
hello-dotnet/
├── hello-dotnet.csproj # Project file
├── Program.cs # Main code
└── obj/ # Build artifacts
3. Look at the Code
Open Program.cs:
// Program.cs - .NET 8 with top-level statements
Console.WriteLine("Hello, World!");
Simple, right? In .NET 8, you don’t need boilerplate like namespace and a Main() method for simple programs.
4. Run the Application
dotnet run
Output:
Hello, World!
C# Basics
C# is the primary language for .NET. Here are some fundamentals:
Variables and Types
// Variable declarations
string name = "Anjar";
int age = 25;
double height = 175.5;
bool active = true;
// Using var (type inference)
var city = "Jakarta"; // automatically becomes string
var year = 2024; // automatically becomes int
String Interpolation
string name = "Anjar";
int age = 25;
// Old way (concatenation)
Console.WriteLine("Name: " + name + ", Age: " + age);
// Modern way (interpolation) — much more readable!
Console.WriteLine($"Name: {name}, Age: {age}");
Collections
// Array
string[] fruits = { "Apple", "Orange", "Mango" };
// List (dynamic size)
List<string> hobbies = new List<string> { "Coding", "Gaming" };
hobbies.Add("Reading");
// Dictionary
Dictionary<string, int> grades = new Dictionary<string, int>
{
{ "Math", 90 },
{ "English", 85 }
};
Loops
// For loop
for (int i = 0; i < 5; i++)
{
Console.WriteLine($"Iteration {i}");
}
// Foreach
foreach (var item in fruits)
{
Console.WriteLine(item);
}
// While
int counter = 0;
while (counter < 3)
{
Console.WriteLine($"Counter: {counter}");
counter++;
}
Recommended Tools
IDE / Editor
- Visual Studio 2022 (Windows/Mac) — Full-featured IDE, free for personal/small teams
- VS Code — Lightweight, cross-platform, with the C# Dev Kit extension
- JetBrains Rider — Powerful, paid, cross-platform
VS Code Extensions
# Install C# Dev Kit
code --install-extension ms-dotnettools.csdevkit
Next Steps
Once you’ve got the basics down, continue with:
- C# Basics — Deeper dive into language syntax and features
- ASP.NET Core — Building web applications
- Entity Framework — Database access
Resources
Congratulations! You’ve taken your first steps with .NET. In the next article, we’ll dive deeper into C# features.