Bald Bearded Builder
topics/csharp

/csharp

The language itself. Pattern matching, nullable reference types, records, and the features people skip because the old way still compiles.

Articles filed under csharp

Article

Virtual vs Override vs Partial in C# Explained with Small Runnable Examples

Virtual, override and partial are tiny C# keywords with huge impact on design. This post explains how they work, when to use them, and where bugs appear. Learn the difference between override and new, why sealed override matters, and how partial classes and partial methods keep generated and hand written code happy. Every section comes with short, runnable snippets and real project tips.

4 min1 like0 comments
Article

Sealed by Default in .NET: when it Shines and when it Bites

Sealed looks like a tiny keyword, but it carries serious weight in modern .NET. This post explains what sealed does at class and member level, why the JIT can make sealed code faster, when you should not seal, and how to keep code testable with interfaces. You will see small, runnable examples and practical patterns that balance performance, clarity, and flexibility.

5 min0 likes0 comments
Article

Smarter Error Handling in C#: Try, Result and Fewer Tears

Exceptions are powerful for diagnostics but expensive in tight loops and high traffic code. This post explains what the runtime does when you throw, why that cost adds up, and when exceptions are the right tool. You will see small, runnable C# examples that model expected failures with Try, Result and tuples, plus a minimal API that returns HTTP results without throwing. We will also cover a micro tip for library authors to keep fast paths fast.

5 min0 likes0 comments
Article

Stop Parallelizing Everything: A Practical Guide to Parallel.ForEach

Parallel.ForEach feels like a free speed boost, until it slows your app to a crawl. This post explains when parallel loops shine, when they backfire, and how to avoid the classic traps. You will see small runnable C# examples for CPU bound work, shared state pitfalls, and I/O scenarios. We will also cover safer async alternatives, thread local aggregation, and simple tuning with ParallelOptions. By the end, you will know how to pick the right approach and measure the impact with confidence.

4 min0 likes0 comments
Article

The Traps of Nullable<T> in C#: a Practical Guide with Tiny Examples

Nullable<T> is not a mini reference type and pretending it is will bite you. This guide walks through how nullable value types work at runtime, how boxing really behaves, and what operator lifting does. You will see small, runnable C# snippets that expose common traps and safe patterns. Learn how to handle equality, pattern matching, and generics without surprises.

5 min0 likes0 comments
Article

Stop Guessing Types in C#: typeof, GetType and IsAssignableFrom Explained

Let's break down the real jobs of typeof, object.GetType and Type.IsAssignableFrom with small, runnable examples and a few nerdy references for fun.

4 min0 likes0 comments
Article

C# 14's Unbound Generics in nameof Explained

C# 14 adds support for unbound generic types in nameof, so you can write nameof(Logger<>) and nameof(Dictionary<,>) without supplying throwaway type arguments. This post explains the syntax, shows practical examples for logs, exceptions, and attributes, and clarifies how nameof differs from typeof in this context.

3 min0 likes0 comments
Article

Alias any Type with C# 12

With C# 12, you can now alias type, including tuples, array, pointer, and unsafe types.

2 min0 likes0 comments
Article

Using Primary Constructors in C# 12 & .NET 8

C# 12 provides a new way to use constructors that can potentially save you time, but there are several things to watch out for.

4 min0 likes0 comments
Article

Building a Cross Platform NuGet Package

Learning to build a NuGet package by building a .NET SDK for the Deepgram API, while ensuring it's compatible with as many versions of the .NET Framework and as many platforms as possible.

5 min0 likes0 comments