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# break statement exiting a loop, with a loop icon and an arrow breaking out.
C#

C# break statement: exit loops and switch cases

Learn how the C# break statement exits loops and switch sections, including nested loop behavior, switch expressions, and common pitfalls.

C#breakcontrol flowloops
Illustration of nested loops represented as concentric rectangles with arrows showing the inner loop completing for each outer iteration.
C#

Using C# Nested For Loops Effectively

Learn how to write and optimize C# nested for loops, understand their runtime cost, and know when to use LINQ or parallel loops.

C# loopsnested loopsperformanceLINQ
Illustration comparing C# for and foreach loops with a performance metric
C#

C# for vs foreach: Choosing the Right Loop

Compare C# for and foreach loops to choose the right iteration style: syntax, allocation behavior, collection types, and code examples.

C#loopsforeachfor loop
Comparison of while and do-while loop condition evaluation order in C#
C#

C# While vs Do While: When to Use Each

Understand the key difference between while and do-while loops in C#, including condition timing, syntax, and practical selection criteria.

C#LoopsControl FlowWhile Loop
Diagram of a C# do while loop showing the body executing once before the condition is checked.
C#

C# Do While Loop: Syntax and Usage

Learn the C# do while loop: guaranteed first execution, syntax, practical use cases, common mistakes, and maintainability tradeoffs.

C# loopsdo whileloop syntaxcontrol flow
Diagram of a C# while loop condition check and iteration
C#

C# While Loop: Syntax, Behavior, and Pitfalls

Learn the C# while loop syntax, how condition evaluation works, and common mistakes to avoid when using while and do-while loops.

C#loopsiterationcontrol flow
Diagram showing a C# for loop with initialization, condition, and iterator steps
C#

C# for Loop: Syntax, Usage, and Performance

Learn the C# for loop syntax, execution flow, common patterns, and performance considerations to write efficient iteration code.

C# loopsiterationperformancecontrol flow
Diagram showing a switch statement with a when clause filtering pattern matches.
C#

Using the when Clause in C# Switch Statements for Pattern Matching

Learn how to use the when clause in C# switch statements to add guard conditions to case patterns. Includes practical examples, common mistakes, and performance considerations.

C#switch statementpattern matchingwhen clause
A visual of logical gates representing C# logical pattern combinators and, or, and not.
C#

C# Logical Pattern

c# logical pattern: Understand C# logical patterns and/or/not, how they combine with property and type patterns, and when they simplify data-validation code.

pattern matchingC#logical operatorsswitch expressions
A visual representation of a C# relational pattern comparing a value against a range, shown as a number on a scale between two bounds.
C#

C# relational pattern

Learn how to use C# relational patterns to write concise, readable comparison logic in switch expressions and property patterns.

pattern matchingswitch expressionsC# syntaxproperty patterns