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 showing multiple C# method signature cards converging into a single resolved overloaded method call
C#

C# Method Overloading: Syntax, Rules, and Practical Use

Learn how C# method overloading works: signature rules, compiler resolution, common mistakes, and when generics or optional parameters fit better.

method overloadingC# syntaxoverload resolutionoptional parameters
Comparison of C# ref, in, and out parameter modifiers with arrows showing data flow.
C#

C# ref vs in vs out: Choosing the Right Parameter Modifier

Understand the differences between C# ref, in, and out parameter modifiers, when to use each, and how they affect performance and code clarity.

C#refinout
Illustration of C# in parameter passing a struct by reference without copying
C#

C# in Parameter: Read-Only References for Structs

Learn how the C# in parameter passes structs by read-only reference, avoids copying for large values, and affects overload resolution and performance.

C#structsmethod parametersread-only
Diagram showing a C# method with an out parameter returning a value to a caller.
C#

C# Out Parameter: How to Use It Correctly

c# out parameter: Learn how to use C# out parameters: syntax, initialization rules, common patterns like TryParse, and when to prefer out over ref or return values.

out parameterC# methodsref vs outTryParse pattern
Diagram showing a ref parameter pointing to the same memory location as the original variable in C#.
C#

C# ref Parameter: How It Works and When to Use It

Understand how C# ref parameters work, when to use them, and how they differ from out and in parameters in practical code.

C#ref keywordmethod parametersvalue types
Illustration of a C# method accepting a variable number of arguments through the params keyword, shown as multiple values flowing into a single array parameter.
C#

Using the C# params Keyword for Variable Arguments

Understand the C# params keyword: syntax, compiler behavior, overload resolution, allocation costs, edge cases, and when an explicit array parameter is a better choice.

C#params keywordvariable argumentsmethod overloading
Diagram showing named arguments mapping parameter names to values in a C# method call.
C#

C# Named Arguments: Syntax and Usage

Learn how to use C# named arguments, including syntax, placement rules, optional parameters, and readability tradeoffs.

C#named argumentsmethod parametersoptional parameters
C# code snippet showing a method with optional parameters and default values
C#

C# Optional Parameters: Syntax, Behavior, and Pitfalls

c# optional parameters: Learn how C# optional parameters work, including default value rules, named arguments, and pitfalls like ambiguous calls.

optional parametersmethod overloadingnamed argumentsdefault values
C# method signature with an optional parameter and a default value, highlighting how the default is baked into the call site.
C#

Using C# Default Parameters Safely

C# default parameters are compiled into callers, so updating a public default may not affect existing consumers. See how optional arguments, named arguments, interfaces, overloads, and API design interact.

optional parametersmethod overloadingnamed argumentsC# syntax
Diagram contrasting a method parameter placeholder with a concrete argument value, symbolizing the C# argument versus parameter distinction.
C#

C# Argument vs Parameter: What's the Difference?

Parameters are declared in a method signature; arguments are values passed at the call site. Learn the difference in C#, including ref, out, and in passing modes.

C# methodsfunction parametersmethod argumentsC# syntax