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 illustrating C# int to string conversion methods with culture and formatting options.
C#

C# Int to String Conversion: Methods and Pitfalls

Understand C# int-to-string conversion: ToString, Convert.ToString, string interpolation, culture-aware formatting, and common pitfalls to avoid.

C#.NETToStringstring formatting
Illustration of a C# code snippet showing a type conversion with a shield symbol representing safe casting.
C#

C# Casting: Safe and Explicit Type Conversion

Learn how C# casting works: explicit casts, the as and is operators, boxing/unboxing, and common pitfalls with practical examples.

C#Type ConversionExplicit Castas Operator
Diagram showing explicit conversion from a base type to a derived type with a cast operator in C#
C#

C# Explicit Conversion: Syntax and Use Cases

Learn how C# explicit conversion works, when to use casts, and how to avoid common pitfalls with user-defined and built-in conversions.

explicit conversioncast operatortype conversionuser-defined conversion
Illustration of C# implicit conversion showing a safe automatic type transformation between containers.
C#

C# Implicit Conversion: How It Works and When to Use It

c# implicit conversion: Learn how C# implicit conversions work, how to define custom implicit operators, and when to avoid them to prevent data loss and bugs.

C#implicit conversionconversion operatorstype safety
Illustration of C# type conversion showing implicit and explicit casts between numeric types
C#

C# Type Conversion: Implicit, Explicit, and Safe Casting

Understand C# type conversion: implicit vs explicit casts, Convert and Parse methods, TryParse for safe user input, and the as operator for reference types.

C#type conversioncastingConvert
Diagram showing nullable and non-nullable reference type annotations in C# code
C#

C# Non-Nullable Reference Type Syntax

Learn the C# non-nullable reference type syntax: enable the nullable context, use the ? and ! operators, and handle compiler warnings in new and legacy code.

nullable reference typesC# syntaxnull safetycompiler warnings
Illustration of C# nullable reference type syntax showing a question mark on a reference type.
C#

Understanding C# Nullable Reference Type Syntax

Learn how to use C# nullable reference type syntax, including enabling nullable annotations, declaring nullable and non-nullable references, using the null-forgiving operator, and handling compiler warnings during migration.

C#Nullable Reference TypesNull SafetyCompiler Warnings
Diagram showing nullable reference type annotations and compiler warnings in C#.
C#

C# Nullable Enable Usage: Syntax and Patterns

c# nullable enable usage: Learn how to enable and use C# nullable reference types, interpret compiler warnings, and apply practical patterns for safer code.

nullable reference typesC#compiler warningstype safety
Editorial illustration showing a C# code editor panel with a question mark symbol inside a shield, representing compile-time null safety.
C#

Using C# Nullable Reference Types in Real Code

c# nullable reference type usage: Learn how to use C# nullable reference types: enabling the context, annotating with ?, handling warnings, and applying null-analysis...

nullable reference typesnull safetyC# compiler warningscode analysis
Diagram showing a nullable int variable with a value and null state, illustrating HasValue and Value access.
C#

C# Nullable Int Usage: Syntax, Checks, and Pitfalls

Learn how to declare, check, and safely read nullable int values in C#. Covers int? syntax, HasValue checks, safe retrieval, common pitfalls, and performance characteristics.

C#nullableintnull handling