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

Illustration of a C# exception object containing a nested inner exception, representing the original error preserved inside a wrapped exception.
C#

Using InnerException in C# to Preserve the Original Error

Learn how C# InnerException preserves the original error when exceptions are wrapped, and how to access the root cause in catch blocks.

C#Exception HandlingInnerExceptionError Handling
A C# custom exception class hierarchy diagram showing a derived exception class with inner exception and serialization.
C#

C# Custom Exception Class: How to Build One

Learn when and how to create a C# custom exception class, including the standard constructors, serialization, and choosing between built-in and custom exceptions.

C#ExceptionsError Handling.NET
Illustration of parsing a string into a C# enum value with a validation gate
C#

C# Enum TryParse: Safe String-to-Enum Parsing

Learn how to parse strings into C# enums safely with Enum.TryParse, including case handling, numeric strings, undefined values, and performance trade-offs.

C#EnumParsingType Safety
Illustration of converting a text string into an enum value in C# with a gear and code symbol.
C#

C# Enum Parse: Converting Strings to Enum Values

c# enum parse: Learn how to parse strings into C# enum values safely, handle invalid input, and manage case sensitivity and flags enums.

enumparsingC#.NET
Diagram showing static and instance members in C# with memory allocation and object references.
C#

C# static vs instance: Key Differences

c# static vs instance: Learn the key differences between static and instance members in C#, including memory, thread safety, and when to use each.

static membersinstance membersC# programmingobject-oriented design
Illustration of a C# static class as a sealed container with shared static members.
C#

C# Static Class: Usage, Limitations, and Tradeoffs

C# static classes: syntax, behavior, use cases, and tradeoffs for utility and helper code.

C#Static ClassObject-Oriented ProgrammingCode Organization
Diagram showing C# protected internal access combining derived class and same-assembly visibility
C#

C# Protected Internal: Union Access Explained

c# protected internal: Learn how C# protected internal combines protected and internal access, when to use it, and how it differs from private protected.

C# access modifiersprotected internalC# inheritanceC# visibility
Diagram comparing C# object creation methods including constructors, factories, and dependency injection.
C#

C# Object Creation: Choosing the Right Approach

Explore C# object creation techniques and when to use them: constructors, object initializers, factory methods, dependency injection, and reflection.

C#Object InitializationFactory PatternDependency Injection
Illustration of a C# class declaration showing the class keyword, a class name, and braces, with subtle icons for access modifiers and inheritance.
C#

C# Class Declaration: Syntax and Variations

C# class declaration syntax and variations: access modifiers, inheritance, static and partial classes, nested types, and common declaration mistakes.

C#class declarationobject-oriented programmingaccess modifiers
Diagram showing a ref local variable pointing to the same memory location as an array element
C#

C# ref local: aliasing variables without copying

Learn how C# ref locals alias existing storage without copying, work with ref returns, and follow compiler restrictions. Includes practical examples and guidance.

C#ref localref returnsperformance