How to split strings efficiently in C#

Optimizing the performance of your .NET applications requires efficient resource management. Memory allocations and deallocations must be performed optimally in performance-critical applications. One of the best strategies to perform resource management in an optimal way in an application is by allocating and deallocating string objects judiciously. C# provides the string.Split() method to split strings in…

Read More

Microsoft .NET Community Toolkit backs partial properties

Microsoft has released .NET Community Toolkit 8.4, with support for partial properties in MVVM Toolkit source generators as well as new MVVM Toolkit diagnostic analyzers. The update was unveiled December 12. Source code for the .NET Community Toolkit can be found on GitHub. Partial properties now are available thanks to new C# language features in…

Read More

How to chunk data using LINQ in C#

Language-Integrated Query, or LINQ for short, brings a query execution pipeline directly into C# and the managed environments of .NET Framework and .NET Core. LINQ provides several ways to execute queries and handle complex data manipulation tasks. Chunking is one feature of LINQ that simplifies the way you manage collections. In this article, we’ll examine…

Read More

How to use DispatchProxy for AOP in .NET Core

Aspect-oriented programming (AOP) decomposes an application’s source code into distinct aspects that isolate the core business logic from cross-cutting concerns. With AOP, cross-cutting concerns like logging and authentication become “aspects” that you program in one place and then apply in all of the places they’re needed. Thus AOP enhances modularity, makes your code more readable…

Read More

Why use aspect-oriented programming

Aspect-oriented programming (AOP) is a programming style that allows you to more easily manage the cross-cutting concerns in your application, meaning those concerns such as authentication or logging that cut across many parts of the app. In essence, AOP is a programming paradigm that enables you to avoid duplicating code and to keep your application…

Read More

How to use Task.WhenEach in .NET 9

The upcoming release of .NET 9 introduces the Task.WhenEach method, which enables developers to handle asynchronous tasks more elegantly. The Task.WhenEach method allows us to iterate through tasks as they complete, without having to call Task.WaitAny repeatedly in order to select the next task that completes. Task.WhenEach will be beneficial particularly in scenarios where you…

Read More

How to use extension methods in C#

In the C# programming language, extension methods enable you to extend the functionality of existing types without modifying them or deriving new types from them using inheritance. You don’t need to create subclasses of existing classes or recompile or modify your existing classes to use extension methods. Extension methods improve the readability of your code…

Read More

How to work with FusionCache in ASP.NET Core

Caching has long been one of the most successful and proven strategies for enhancing application performance and scalability. There are several caching mechanisms in .NET Core including in-memory caching (IMemoryCache API), distributed caching (IDistributedCache API), and the new hybrid caching (HybridCache API), which will be a part of .NET 9 to be released in November…

Read More

Best practices for handling exceptions in C#

Exception handling is the technique of handling runtime errors in your application code. Basically, you have two categories of exceptions: Exceptions that are generated by the application and exceptions that are generated by the runtime. Exceptions should be handled with care. You should have a good idea of how exceptions should be handled and when…

Read More