BrandGhost
← Back to C# & .NET

Language Features

Articles

When to Use Enum vs Constants in C#: Decision Guide

Struggling with enum vs const in C#? This decision guide covers type safety, extensibility, serialization, and the enumeration class pattern to help you choose correctly.

Read the whole article

How to Use Enum in C#: Declaration, Values, and Best Practices

How to Use Enum in C#: Declaration, Values, and Best Practices

Learn how to use enum in C# from scratch. Covers declaring enums, assigning values, casting, comparing, iterating, and the best practices every C# developer should follow.

Read the whole article

How to Create Your First C# Source Generator (Step-by-Step)

How to Create Your First C# Source Generator (Step-by-Step)

Learn how to create a C# source generator with .NET 10. Step-by-step guide covering project setup, IIncrementalGenerator implementation, and packaging.

Read the whole article

Iterator Benchmarks That Shocked With Unexpected Results

I wanted to create a follow-up post in my series on IEnumerables, iterators, and collections focusing on performance characteristics. When checking out the runtime performance and memory characteristics between these materialized collections and iterator benchmarks, I was very surprised! Check out this article for performance benchmark characteristics and some curious finds.

Read the whole article

Async EventHandlers - A Simple Safety Net to the Rescue

Async event handlers in C# are tricky: an async void event handler can swallow exceptions and crash your app. Use this simple safety-net pattern to handle them.

Read the whole article

An error has occurred. This application may no longer respond until reloaded. Reload