Synchronization Mechanisms – Volatile vs Interlocked vs lock in C#
When we apply multithreading to increase the speed and efficiency of our applications, synchronization plays an essential role for it to be effective. It maintains order when multiple threads try accessing the same resource. In this article, we'll explore different...
Different Ways to Overwrite a File in C#
In C#, we encounter various scenarios where we might need to overwrite an existing file. Whether to update the file or completely overwrite it, handling the overwrite efficiently is crucial to ensure data integrity and prevent data loss. In this article, we will...
Code Maze Weekly #185
Issue #185 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Building a Resilient Email Sending Method in .NET with SmtpClient, Retry Support, and the Outbox Pattern [ardalis.com] Sending...
How to Use onchange Event with Select DropDown in Blazor
When we write applications, we want to know when a user changes the value in input fields and what the new value is. We get this information through change events available for HTML input-type elements. We can define an onchange event attribute on the input element to...
How to Use Moq to Return a Value That Was Passed Into a Method?
In this article, we are going to learn about mocking with the Moq framework for .NET. Specifically, we're going to learn how we can mock a method, which returns a value passed to it. The more complex the...
How to Use Basic Authentication With HttpClient?
In this article, we are going to discuss how to use basic authentication with HttpClient. While the topic may seem straightforward, there are a few different ways to solve this problem. We'll try and cover some of the main approaches, and hopefully, by the end, we...
Testing Using Testcontainers for .NET and Docker
In this article, we'll explore how to use the Testcontainers library for testing .NET applications using Docker. Let's get...
Differences Between Any and Exists Methods in C#
In this article, we will explore the differences between Any() and Exists() methods in C#. Although at first glance they might seem similar, they possess distinct characteristics and we use them in different scenarios in order to manipulate data collections. Visual Studio is a great tool. But it has so many...
Optimistic Concurrency in ASP.NET Core Web API
In this article, we'll discuss a few approaches to implementing optimistic concurrency in ASP.NET Core Web API. Let's begin. Understanding...
How to Return HTTP 500 From ASP.NET Core Web API
In this article, we will learn about the different ways to return a 500 status code with ASP.NET Core Web API controller actions. Let's start!...
Dynamically Switching DbContext at Runtime Using Entity Framework Core
In this article, we will discuss why having multiple databases behind an application is useful and how dynamically switching an EF DbContext can be achieved without experiencing downtime. Feel free to check out our series of articles on Entity Framework Core. [sc...
How to Get a JSON Array Using IConfiguration in ASP.NET Core
In this article, we will explore how to get a JSON array using IConfiguration. In modern web applications, JSON is a widely used data interchange format due to its lightweight nature and ease of use. When developing an ASP.NET Core application, it is common to store...