C# Archives - Code Maze https://code-maze.com/category/csharp/ Learn. Code. Succeed. Wed, 26 Feb 2025 08:47:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.5 https://code-maze.com/wp-content/uploads/2020/01/Code-Maze-Favicon.png C# Archives - Code Maze https://code-maze.com/category/csharp/ 32 32 Measure Application Performance in .NET Using IMeterFactory https://code-maze.com/dotnet-imeterfactory-application-performance/ https://code-maze.com/dotnet-imeterfactory-application-performance/#respond Wed, 26 Feb 2025 08:47:52 +0000 https://drafts.code-maze.com/?p=122235 Performance monitoring is essential for ensuring that our applications run efficiently and reliably. .NET offers a set of tools to help with this, accessible via IMeterFactory. In this article, we’ll learn how to use these tools to check the health of our applications, measure performance, and collect data for optimization. So let’s get going. What […]

The post Measure Application Performance in .NET Using IMeterFactory appeared first on Code Maze.

]]>
https://code-maze.com/dotnet-imeterfactory-application-performance/feed/ 0
Persist Values With AsyncLocal in C# Async Flow https://code-maze.com/csharp-persist-values-with-asynclocal-in-async-flow/ https://code-maze.com/csharp-persist-values-with-asynclocal-in-async-flow/#respond Mon, 06 Jan 2025 05:55:32 +0000 https://code-maze.com/?p=123739 In this article, we’ll explain the AsyncLocal class and how to persist values across an async flow with the AsyncLocal class in C#. We’ll start by describing the challenge that AsyncLocal solves and continue with examples of how it does that. We’ll scratch the surface of the AsyncLocal inner workings and finish with the cases […]

The post Persist Values With AsyncLocal in C# Async Flow appeared first on Code Maze.

]]>
https://code-maze.com/csharp-persist-values-with-asynclocal-in-async-flow/feed/ 0
Chain of Responsibility Design Pattern in C# https://code-maze.com/csharp-chain-of-responsibility-design-pattern/ https://code-maze.com/csharp-chain-of-responsibility-design-pattern/#respond Mon, 09 Dec 2024 06:56:56 +0000 https://drafts.code-maze.com/?p=121693 In this article, we will talk about the Chain of Responsibility Design Pattern. We are going to see how to implement this pattern in C# and how it can solve certain design problems. Let’s start. What is The Chain of Responsibility Design Pattern? Chain of Responsibility is a behavioral pattern that helps us design a […]

The post Chain of Responsibility Design Pattern in C# appeared first on Code Maze.

]]>
https://code-maze.com/csharp-chain-of-responsibility-design-pattern/feed/ 0
Optimistic Locking vs Pessimistic Locking in .NET https://code-maze.com/dotnet-optimistic-locking-vs-pessimistic-locking/ https://code-maze.com/dotnet-optimistic-locking-vs-pessimistic-locking/#respond Mon, 25 Nov 2024 05:56:43 +0000 https://code-maze.com/?p=123686 Since the invention of database systems, they have become the primary source of truth for almost every web application’s data. As user demands grow, applications scale, and so does the concurrency within the system. Ensuring data integrity and consistency along with effective locking mechanisms, becomes a major concern when multiple users attempt to access and […]

The post Optimistic Locking vs Pessimistic Locking in .NET appeared first on Code Maze.

]]>
https://code-maze.com/dotnet-optimistic-locking-vs-pessimistic-locking/feed/ 0
Early Binding and Late Binding in C# https://code-maze.com/csharp-binding/ https://code-maze.com/csharp-binding/#respond Mon, 18 Nov 2024 07:54:07 +0000 https://code-maze.com/?p=123680 In C#, method binding refers to associating a method call with the method’s code definition. When we invoke a method, the program determines which specific method to execute. This process, known as “binding,” can occur at two different times: during compile-time (early binding) or runtime (late binding). By using early binding, we can use compile-time […]

The post Early Binding and Late Binding in C# appeared first on Code Maze.

]]>
https://code-maze.com/csharp-binding/feed/ 0
How to Use Pointers in C# https://code-maze.com/csharp-how-to-use-pointers/ https://code-maze.com/csharp-how-to-use-pointers/#respond Mon, 11 Nov 2024 07:55:01 +0000 https://code-maze.com/?p=123660 In this article, we’ll introduce pointers in C#, exploring their syntax, usage in unsafe code blocks, and practical applications with direct memory manipulation. We’ll also discuss considerations involved in using pointers in a managed language. Let’s start! What Is a Pointer in C#? A pointer is simply a variable that holds the memory address of […]

The post How to Use Pointers in C# appeared first on Code Maze.

]]>
https://code-maze.com/csharp-how-to-use-pointers/feed/ 0
How to Get an Instance of IServiceProvider in .NET https://code-maze.com/dotnet-get-an-instance-of-iserviceprovider/ https://code-maze.com/dotnet-get-an-instance-of-iserviceprovider/#respond Mon, 28 Oct 2024 07:21:16 +0000 https://code-maze.com/?p=123560 In modern .NET applications, dependency injection is a fundamental design pattern that promotes loose coupling and enhances maintainability. At the center of .NET’s dependency injection system lies the IServiceProvider interface, which acts as a service locator for retrieving service instances. Understanding how to obtain and work with an IServiceProvider instance is vital for developers who […]

The post How to Get an Instance of IServiceProvider in .NET appeared first on Code Maze.

]]>
https://code-maze.com/dotnet-get-an-instance-of-iserviceprovider/feed/ 0
Entity Framework Core Best Practices https://code-maze.com/entity-framework-core-best-practices/ https://code-maze.com/entity-framework-core-best-practices/#comments Mon, 21 Oct 2024 04:47:44 +0000 https://code-maze.com/?p=123550 Entity Framework Core (EF Core) is an object-relational mapper (ORM), enabling us to work with a database using .NET objects, eliminating much of the data-access code we usually need to write. EF Core supports many databases, including SQL Server, SQLite, PostgreSQL, MySQL, and more, making it highly versatile. While EF Core provides many conveniences, following […]

The post Entity Framework Core Best Practices appeared first on Code Maze.

]]>
https://code-maze.com/entity-framework-core-best-practices/feed/ 2
Mediator Design Pattern in C# https://code-maze.com/csharp-mediator-design-pattern/ https://code-maze.com/csharp-mediator-design-pattern/#respond Mon, 16 Sep 2024 02:55:15 +0000 https://drafts.code-maze.com/?p=121141  In this article, we are going to talk about a popular design pattern, the Mediator Pattern. We will see how this pattern helps address some design problems and how to implement it in C#. Let’s start. What is The Mediator Design Pattern? Mediator is a behavioral design pattern that promotes loose coupling by eliminating chaotic […]

The post Mediator Design Pattern in C# appeared first on Code Maze.

]]>
https://code-maze.com/csharp-mediator-design-pattern/feed/ 0
Manage Background Tasks With The IHostedLifecycleService Interface https://code-maze.com/aspnetcore-ihostedlifecycleservice-interface/ https://code-maze.com/aspnetcore-ihostedlifecycleservice-interface/#respond Thu, 12 Sep 2024 06:01:12 +0000 https://code-maze.com/?p=123342 In this article, we’ll describe the IHostedLifecycleService interface. We’ll see how it extends the IHostedService interface and enables finer control over the hosted service lifecycle. Finally, we’ll show some practical use cases for the IHostedLifecycleService interface. Let’s get started.  What Is the IHostedService Interface The IHostedService interface is a powerful feature in .NET that enables […]

The post Manage Background Tasks With The IHostedLifecycleService Interface appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-ihostedlifecycleservice-interface/feed/ 0