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

Diagram of a C# class showing fields, properties, methods, and events as building blocks.
C#

Understanding C# Class Members

Learn how C# class members define data and behavior: fields, properties, methods, constructors, events, nested types, and static members with practical examples.

class memberspropertiesmethodsconstructors
Diagram showing the three uses of the c# new keyword: object creation, member hiding, and generic constraint.
C#

Understanding the C# new Keyword: Operator, Modifier, and Constraint

Learn the three roles of the C# new keyword: the new operator, the new modifier, and the new() constraint, with code examples and common pitfalls.

C#new operatormember hidinggeneric constraints
Diagram showing a method returning a reference to an array element, with an arrow pointing to the original storage location.
C#

C# Ref Return: Syntax, Usage, and Performance

Understand C# ref returns: syntax, ref locals, restrictions, and the performance tradeoffs of returning references to array elements and fields.

ref returnref localsC# performanceC# syntax
Illustration of a C# method receiving an array reference, showing that the caller and method share the same array object.
C#

Passing an Array to a Method in C#: Syntax and Behavior

Learn how C# passes arrays to methods as references, including params, ref, and ReadOnlySpan for read-only access.

C# ArraysMethod Parametersparams KeywordReadOnlySpan
A compact arrow symbol transforming a multi-line method block into a single-line expression, illustrating the C# expression-bodied method syntax.
C#

C# Expression-Bodied Method: Syntax and Usage

Learn how C# expression-bodied methods simplify single-expression logic, where the syntax applies, and when a block body is the clearer choice.

C#Expression-Bodied MembersMethod SyntaxCode Readability
Illustration of a C# local function nested inside a method, showing scope and encapsulation.
C#

C# Local Function: Syntax, Use Cases, and Performance

Learn how C# local functions work, when they are a better choice than lambda expressions, and how they affect performance and code clarity.

C#Local FunctionsLambda ExpressionsPerformance
Diagram of a C# recursive method showing base case and recursive calls on a call stack.
C#

C# Recursive Method: Syntax, Stack, and Pitfalls

c# recursive method: Learn how to write C# recursive methods, understand base cases, call stack behavior, and avoid stack overflow pitfalls.

C#RecursionCall StackIteration
A diagram showing a C# method returning a tuple with named elements and deconstruction at the call site.
C#

C# Tuple Return: Syntax and Usage

Learn how to return multiple values from C# methods with tuples, use named elements, deconstruct results, and choose between Tuple and ValueTuple for performance and clarity.

C#ValueTupleTuple DeconstructionNamed Tuples
Illustration of a C# method returning multiple values using a tuple, showing the concept of multiple return values.
C#

C# Return Multiple Values: Tuples, Out Parameters, and Custom Types

Learn how to return multiple values from C# methods using tuples, out parameters, and custom types, with code examples and tradeoffs.

C#TuplesOut ParametersValueTuple
Diagram showing multiple method signatures with the same name resolving to different implementations in C#.
C#

C# Method Overloading Rules: How Resolution Works

Understand C# method overloading: valid signatures, overload resolution, optional and named arguments, ref/out/in, params arrays, and common ambiguity pitfalls.

C#Method OverloadingOverload ResolutionMethod Signatures