Cart
C# and .NET have been around long enough to prove they’re not a trend. They run on Windows, macOS, and Linux, power everything from APIs to desktop apps to games, and the tooling is friendly even when you’re new. If you’ve been thinking about picking up a language that can take you from “Hello, World” to full products without switching stacks every week, this is a solid bet.
This post gives you a quick tour of what C#/.NET looks like today (latest SDK), what you can build in your first month, and a couple of tiny code samples to get you moving.
You don’t need a giant setup to begin. The dotnet
CLI and a text editor will carry you very far.
Along the way, add unit tests so you trust your changes.
Create and run a tiny API:
dotnet new web -n HelloApi
cd HelloApi
dotnet run
Open Program.cs
and add two endpoints:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "API is up");
app.MapGet("/hello/{name}", (string name) =>
Results.Json(new { message = $"Hello, {name}" }));
app.Run();
You now have a running HTTP server. Hit http://localhost:5000/hello/Nick
and you’ll get a JSON response.
C# reads well and has a few small features that save a lot of code.
Records (immutable data with value equality):
public sealed record Customer(string Id, string Email);
Pattern matching (clear branching without nested if
s):
static decimal DiscountFor(int items) => items switch
{
<= 0 => 0m,
1 or 2 => 0.05m,
<= 10 => 0.10m,
_ => 0.15m
};
Async/await (non-blocking I/O):
using var http = new HttpClient();
var json = await http.GetStringAsync("https://example.com/data");
// continue without blocking a thread
LINQ (expressive collection queries):
var top = orders
.Where(o => o.Total > 100)
.OrderByDescending(o => o.CreatedAt)
.Take(5)
.Select(o => new { o.Id, o.Total });
You can write clear, compact code without clever tricks.
Let’s combine a few ideas—Minimal API, validation, and a simple in-memory store (later you can swap for EF Core).
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
var items = new Dictionary<Guid, CatalogItem>();
app.MapPost("/items", (CreateItem req) =>
{
if (string.IsNullOrWhiteSpace(req.Name)) return Results.BadRequest("Name is required");
if (req.Price < 0) return Results.BadRequest("Price must be >= 0");
var item = new CatalogItem(Guid.NewGuid(), req.Name.Trim(), req.Price);
items[item.Id] = item;
return Results.Created($"/items/{item.Id}", item);
});
app.MapGet("/items/{id:guid}", (Guid id) =>
items.TryGetValue(id, out var item) ? Results.Ok(item) : Results.NotFound());
app.MapGet("/items", () => items.Values);
app.Run();
public sealed record CreateItem(string Name, decimal Price);
public sealed record CatalogItem(Guid Id, string Name, decimal Price);
This style scales surprisingly well. When the logic grows, move it into plain classes and keep the endpoints thin.
dotnet new
— create projects (web
, console
, classlib
, xunit
, mstest
).dotnet add package
— install libraries from NuGet.dotnet run
/ dotnet test
/ dotnet build
— daily commands you’ll memorize in a day.Unit tests keep you honest as your code grows. Here’s a quick example with xUnit and Shouldly (license-friendly).
dotnet new xunit -n GettingStarted.Tests
dotnet add GettingStarted.Tests package Shouldly
using Shouldly;
public class DiscountTests
{
[Theory]
[InlineData(0, 0)]
[InlineData(2, 0.05)]
[InlineData(5, 0.10)]
[InlineData(50, 0.15)]
public void Calculates_expected_discount(int items, decimal expected)
=> DiscountFor(items).ShouldBe(expected);
static decimal DiscountFor(int items) => items switch
{
<= 0 => 0m,
1 or 2 => 0.05m,
<= 10 => 0.10m,
_ => 0.15m
};
}
Run dotnet test
and you get instant feedback.
It’s common to see teams ship an API, a small admin tool, and a scheduled worker—all in C#—which keeps hiring and maintenance simple.
dotnet --info
.List<T>
, LINQ. Write a small CSV parser or a file renamer.Stick to this and you’ll avoid a lot of pain.
DateTime.UtcNow
, random, or GUIDs. Abstract them behind interfaces so tests can control time and IDs.
Nick Chapsas is a .NET & C# content creator, educator and a Microsoft MVP for Developer Technologies with years of experience in Software Engineering and Engineering Management.
He has worked for some of the biggest companies in the world, building systems that served millions of users and tens of thousands of requests per second.
Nick creates free content on YouTube and is the host of the Keep Coding Podcast.
More courses by Nick Chapsas© 2025 Dometrain. All rights reserved.