Tag Archives: C#

C# – Dapper vs EF for CRUD operations

By | 12/07/2023

In many articles and websites, there are many examples of how Dapper is faster than EF to select data in a database.In this post instead, I want to check if Dapper is faster than EF for some CRUD operations like Insert, Update and Delete.I have this curiosity because I have seen that there is an… Read More »

Category: C# Tags:

C# – Optimizing performance with Parallel.For

By | 21/06/2023

In this post, we will see how to use Parallel.For to optimize the performance of our applications.But first of all, what is Parallel.For?“The Parallel For loop is part of the System.Threading.Tasks namespace introduced in .NET Framework 4.0. It provides a convenient way to divide a loop iteration into smaller, independent tasks that can be executed… Read More »

Category: C# Tags:

C# – Stopwatch

By | 05/04/2023

In this post, we will see what StopWatch is and how we can use it.But first of all, what is StopWatch?The Stopwatch class is a high-resolution timer provided by the .NET Framework, designed to measure the elapsed time for an operation or a block of code. It’s part of the System.Diagnostics namespace and offers greater… Read More »

Category: C# Tags:

C# – The fastest ways to iterate a List

By | 22/03/2023

In this post, we will see the fastest ways to iterate a List. We start creating a Console Application called ReadList and then, we add a Class called Core: [CORE.CS] Now, we will add four methods to iterate the List using the statements For, Foreach, List<T>.Foreach and Foreach with CollectionsMarshal.AsSpan: FOR(We are not sure that… Read More »

Category: C# Tags:

Asynchronous Programming – ValueTask

By | 15/03/2023

In this post, we will see what ValueTask is and how to use it in our projects.But first of all, what is ValueTask?From Microsoft web site:“A ValueTask is a structure that can wrap either a Task or a IValueTaskSource instance. Returning a ValueTask that wraps a IValueTaskSource instance from an asynchronous method enables high-throughput applications… Read More »

C# – Big O notation

By | 08/02/2023

In this post, we will see what Big O notation is and how to use it to optimize our algorithms.But first of all, what is Big O notation?From Wikipedia:“Big O notation is a mathematical notation that describes the limiting behaviour of a function when the argument tends towards a particular value or infinity. Big O is a member of a family of notations invented by Paul Bachmann,… Read More »

C# – BenchmarkDotNet

By | 07/12/2022

In this post, we will see how to use the library BenchmarkDotNet for testing the performance of our methods.But first of all, what is BenchmarkDotNet?“BenchmarkDotNet is a lightweight, open-source, powerful .NET library that can transform our methods into benchmarks, track the performance, and then provide insights into the performance data captured”.I want to specify that… Read More »

Category: C# Tags: