Strategy design pattern in C#


Strategy is a design pattern where a set of rules is defined and allows us to have different implementations. For example, suppose we want to write a repository for reading data that allows us to change where the data is read (with minimal changes to the code) in the future. We can store ....
Read more

How is null stored in ValueTypes in c#?


In C#, there are two types of data types: ValueType and ReferenceType. These types have their own unique characteristics. One of the features we want to discuss in this article is the ability to assign a Null value to ValueTypes. ReferenceTypes do not store the actual data; instead, they store ....
Read more

Implementing FileHelper for compatibility with all operating systems in Asp.Net Core


When working with files in C#, we usually consider them to work correctly on all operating systems, as file paths differ between Windows, Linux, and macOS. For example, in Windows, we use "\" to separate directories, while in Linux, "/" is used. If we have specified paths in our code ....
Read more

Use ThrowHelper instead of throw new Exception


When we want to raise an error in the program, we usually use throw new exception and put the appropriate text of the error in the exception class. But if the number of these export errors increases, it will increase the assembly code. ....
Read more

Performance tip about List


If we want to maintain a list of data, the first way that comes to mind is List or Array. In this article, we want to review a point about the space occupied by List. The List class uses an internal array to store elements. ....
Read more

Dapper does cache the query strings


When you use Dapper to read information, add information, etc., in the Dapper library, your written query is stored in a ConcurrentDictionary, so that if the same query is run again, the process to run the query again will not run. ....
Read more

Eliding async await


Normally, methods written async do not run faster than sync methods and only allow the system to respond to more requests. This topic was presented in the article How Thread pool works. ....
Read more

Wrong exception line number in stack trace in release mode


A few days ago, in one of the projects I was working on, an Object reference not set to an instance of an object error was issued, and the line where the error was issued was line 61 in the logs. When I checked line 61 ....
Read more

The difference between throw and throw ex


throw, reissues the error with the same StackTrace as before. issues exactly the same error as before. But if you use throw ex, it still issues the same error as before, but with one difference, it resets StackTrace! For example ....
Read more

The difference between async and sync


In the previous article, how the Thread Pool works was presented. In this article, we will examine the differences between async and sync methods, what is the difference between these two types, and why we should use async methods. When you write a method in sync ....
Read more