Pages

Topics

Tools

↑↓navigate↵openescclose

C# guides

Every published C# guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest C# guides

Three feed pipes converging on a package crate with one pipe sealed and a cyan magnifier
C#

NuGet NU1101: unable to find the package in any source

The package is not on any feed this solution queries. Check the inherited source list first, then authentication.

.NETNuGetCIPackage Management
A dependency injection container with one empty socket in its wall and an amber gap
C#

.NET DI: Unable to resolve service for type while attempting to activate

Read the two type names in order, then check registration, namespace and lifetime. Includes the scoped-into-singleton follow-on error.

.NETDependency InjectionASP.NET CoreTroubleshooting
An SDK crate stack with a mismatched version plate and an amber gap, headline SDK NOT FOUND
C#

dotnet: A compatible .NET SDK was not found (global.json)

The message names the file and the missing band. Relax rollForward, pin an installed version, or remove the second pin in CI.

.NETdotnet CLIglobal.jsonCI
A database context block with two overlapping operation arrows, headline SECOND OPERATION
C#

EF Core: A second operation was started on this context instance

A DbContext is not thread-safe. Sequence the work, split it across factories, and stop capturing scoped contexts in background tasks.

C#EF Core.NETConcurrency
3D diagram of a class box with an empty property slot glowing red and an amber key approaching, headline CS8618
C#

CS8618: Non-nullable property must contain a non-null value

Nullable reference types caught a promise the constructor does not keep. Choose required, a constructor parameter, an honest string? or a documented null-forgiving default.

C#.NETNullable Reference TypesCompiler Warnings
3D illustration of stacked code slabs with one detached amber slab and a warning triangle above it
C#

CS0219: The Variable Is Assigned but Its Value Is Never Used

Roslyn reports CS0219 only for locals whose assigned value is dead and side-effect free. How to tell a leftover from a forgotten return, and where to suppress it.

C#.NETCompiler WarningsDebugging
C# collection brackets combining arrays through spread elements into one collection
C#

C# 12 Collection Expressions: Syntax, Spread Operator, and Performance

How C# 12 collection expressions convert to arrays, spans, lists, and builder-backed types, and where the spread element and target-type rules decide performance.

C#Collection ExpressionsC# 12Spread Operator
C# primary constructor parameters captured into a glowing class container
C#

C# Primary Constructors: Syntax, Scope, and Pitfalls

How C# 12 primary constructors work on classes and structs, what the compiler generates, and the property, capture, and validation pitfalls that surprise teams.

C#Primary ConstructorsC# 12Records
Comparison of C# using statement and Dispose method for resource management
C#

C# using vs Dispose: When to Use Each

Understand the difference between C#'s using statement and calling Dispose directly, with practical guidance for IDisposable cleanup and exception safety.

C#IDisposableusing statementresource management
Diagram contrasting explicit Dispose calls with garbage collector finalization timing in C#.
C#

C# Dispose vs Destructor: Key Differences Explained

Dispose runs when you call it; a destructor runs later on the finalizer thread. The Dispose(bool) pattern, double-dispose guards, and when to skip one.

IDisposableFinalizerGarbage CollectionResource Management