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

C# code editor showing default keyword usage with type inference
C#

C# Default Keyword: Syntax and Use Cases

Learn how the C# default keyword works for value types, reference types, generics, and the default literal in modern C#.

C#default keywordgeneric typesdefault literal
Illustration of the C# nameof operator converting a code symbol into a compile-time string literal, representing refactoring-safe string names.
C#

C# nameof Keyword: Compile-Time String Names

The C# nameof keyword produces compile-time string names, preventing magic strings and keeping validation, property-change notification, and logging code refactoring-safe.

nameof operatorC# 6compile-timerefactoring
Illustration of the C# typeof keyword showing a compile-time type reference versus a runtime object type.
C#

C# typeof Keyword: Syntax, Usage, and Runtime Behavior

c# typeof keyword: Learn how the C# typeof keyword works, how it differs from GetType(), and when to use it for type checks, generics, and reflection.

typeof operatorreflectiontype checkingC# generics
Illustration of the C# sizeof keyword showing a memory block with measured byte size and a struct layout.
C#

C# sizeof Keyword: Compile-Time and Runtime Behavior

Learn how the C# sizeof operator returns type sizes, when unsafe context is required for structs, and how it differs from Marshal.SizeOf.

C#sizeof operatorunsafe codeunmanaged types
Illustration of a chain of object nodes where a null node is safely bypassed by the C# null conditional operator.
C#

C# Null Conditional Operator: Syntax and Behavior

Learn how the C# null conditional operator ?. and indexed form ?[] work: short-circuiting, value types, common mistakes, and runtime behavior.

null safetyC# 6nullable typesshort-circuiting
Illustration of a C# null coalescing operator showing two paths merging into a single fallback value.
C#

Using the C# Null Coalescing Operator Effectively

c# null coalescing operator: Learn how the C# null coalescing operator (??) simplifies null handling, its assignment form, and when to prefer it over conditional expre...

null handlingC# operatorsnull-conditionalcode readability
Illustration of the C# ternary operator showing a conditional expression with true and false branches converging into a single result.
C#

C# Ternary Operator: Syntax, Usage, and Pitfalls

Learn how to use the C# ternary operator for concise conditional assignments, avoid common pitfalls, and know when an if-else statement is the clearer choice.

C#Ternary OperatorConditional OperatorC# Syntax
Diagram showing a compound assignment operator combining an arithmetic operation with assignment in C# code.
C#

C# Compound Assignment Operators: Syntax and Behavior

c# compound assignment operators: Learn how C# compound assignment operators work, including syntax, type conversions, precedence, and common pitfalls for working deve...

C# operatorscompound assignmentassignment operatorsC# syntax
Diagram showing left and right shift operations on binary bits in C#.
C#

C# Shift Operators: Syntax and Behavior

Learn how C# shift operators work, including sign extension, masking rules, and practical uses for bit flags and arithmetic.

bit manipulationoperatorsC# syntaxinteger arithmetic
Illustration of the C# XOR operator concept with two binary inputs and an output.
C#

C# XOR Operator: Bitwise and Logical Usage

Learn how the C# XOR operator (^) works for bitwise and logical operations, including examples for bit toggling, flag manipulation, and common mistakes.

C#bitwise operatorslogical operatorsXOR