Task vs ValueTask in C#: Making the Right Choice for Performance

Task vs ValueTask in C#: When to Choose Each One When writing async code in C#, most of us just use Task and Task<T> without thinking twice. But there’s this other option called ValueTask that can actually speed up your code in some situations. Let’s look at what makes these two different and how to pick the right one for your code. The Basics: Task and ValueTask Let’s start with what these two types actually are. ...

June 22, 2025 · 7 min · 1356 words

C# 14's 'params' for Collections: Say Goodbye to Arrays!

Ever used the params keyword in C#? If you write C# code regularly, you probably reach for it whenever you need to pass a variable number of arguments to a method. It’s super handy, letting you skip the tedious step of creating arrays first. But until now, there’s been a limitation: params only worked with arrays. This meant every call created memory allocations with potential performance costs. The good news? C# 14 is changing the game by extending params to work with modern collections like IEnumerable<T>, Span<T>, and more. ...

June 21, 2025 · 6 min · 1194 words

Array vs ArrayList in C#: Understanding the Key Differences

Arrays vs ArrayLists in C#: Which One Should You Pick? If you’ve been coding in C# for a while, you’ve probably used both arrays and ArrayLists. Let’s break down the real differences between these two collection types and talk about when you might want to use each one. The Basics: What’s the Difference? An array in C# is pretty straightforward, it’s a fixed-size collection where all elements must be the same type. Once you create it, that’s it, the size is locked in. ...

June 20, 2025 · 4 min · 657 words

Understanding Delegates vs Events in C#: When and How to Use Each

Introduction to Delegates and Events If you’ve been coding in C# for a while, you’ve probably encountered delegates and events. These two features are incredibly powerful tools that help us write flexible, loosely coupled code. While they might seem similar at first glance (and yes, events are actually built on top of delegates), they each have their own purpose and best use cases. I remember when I first started learning C#, I found it challenging to understand exactly when to use delegates versus events. Over time, I’ve realized that choosing the right tool can make a huge difference in how maintainable and flexible your code becomes. ...

June 20, 2025 · 15 min · 2996 words