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

A developer's screen showing a C# enum value being converted to a string with a formatting overlay.
C#

Formatting C# Enum ToString with Ease

Learn how to control C# enum ToString output, handle undefined values and flags, and choose efficient conversion strategies.

C# enumsToString formattingEnum.GetNameEnum.IsDefined
Illustration of converting a string to an enum value in C# with parsing and validation steps.
C#

C# String to Enum: Parsing and Validation

c# string to enum: Learn how to convert strings to enum values in C# using Enum.Parse and Enum.TryParse, including case handling, validation, and performance considera...

C#enumstring parsingtype conversion
Illustration of an integer value being converted to an enum type in C# with a validation shield.
C#

C# Int to Enum: Casting and Validation

Learn how to convert an int to an enum in C# safely, including casting, Enum.TryParse, and validation with Enum.IsDefined to avoid invalid values.

C# enumsenum conversionEnum.TryParseEnum.IsDefined
Illustration of converting a C# enum to its integer value using a cast operator.
C#

C# enum to int: Cast, Convert, and Underlying Types

Learn how to convert C# enums to int values with explicit casts, Convert.ToInt32, and a clear understanding of underlying types and common pitfalls.

C#enumconversioncasting
Illustration of a C# enum with custom numeric values mapped to named members, showing the relationship between names and underlying integers.
C#

C# Enum Custom Values: How to Define and Use Them

Learn how to define C# enums with custom numeric values, parse them, handle duplicate values, and use them with serialization and switch statements.

enumC#underlying typeparsing
A C# enum declaration example showing named constants and underlying integer values.
C#

C# Enum Declaration: Syntax, Types, and Pitfalls

c# enum declaration: Understand C# enum declaration syntax, underlying types, flags, naming, and versioning to write maintainable and efficient code.

enumcsharptype-safetyflags
C# enum usage illustration showing a set of named constants mapped to numeric values
C#

C# Enum Usage: Practical Patterns and Pitfalls

Learn practical C# enum patterns: declaring and parsing values, iterating members, flags enums, and avoiding common pitfalls.

enumC#flagsEnum.Parse
Diagram showing three different class shapes connected to a central interface node, illustrating C# interface polymorphism
C#

C# Interface Polymorphism Explained with Code Examples

C# interface polymorphism lets different classes be called through a common interface type. See how runtime dispatch works, how it compares with abstract classes, and when it helps.

C# InterfacesPolymorphismOOP DesignDependency Injection
Diagram showing interface inheritance hierarchy in C# with derived interfaces and implementing classes.
C#

C# Interface Inheritance: Syntax and Usage

c# interface inheritance: Learn how C# interfaces inherit from other interfaces, implement derived interfaces, and handle multiple inheritance with practical examples.

interfaceinheritanceC#object-oriented programming
Diagram showing an interface with a default method implementation and a class overriding it.
C#

C# Default Interface Method: Syntax and Compatibility

c# default interface method: Learn how C# default interface methods work, when to use them, and how they affect versioning and compatibility in real projects.

C#InterfacesDefault ImplementationsAPI Versioning