Latest Posts On Code Maze

Fastest Way to Read a Text File in C#

Fastest Way to Read a Text File in C#

In this article, we will find out the fastest way to read a text file in C#. We will discuss and implement various methods that we can use to perform this action. Subsequently, we will compare the performance of these methods using the BenchmarkDotNet library. [sc...

Using ML.NET CLI To Automate Model Training

Using ML.NET CLI To Automate Model Training

As we continue our article series about ML.NET, we will look at the ML.NET Command Line Interface (CLI) tool.  Like ML.NET Model Builder, the ML.NET CLI uses AutoML to produce machine learning models.  [sc name="github"...

When to Use ReaderWriterLockSlim Over lock in C#

When to Use ReaderWriterLockSlim Over lock in C#

In this article, we will explore the lock statement and the ReaderWriterLockSlim class. We will discuss the situations in which it's better to use ReaderWriterLockSlim over lock in C#. We will also compare the ReaderWriterLockSlim class with the ReaderWriterLock class...

Different Log Levels in Serilog

Different Log Levels in Serilog

In this article, we will discuss the different log levels in Serilog and how to configure them. We will explain the log targets offered by Serilog for writing logs. Additionally, we will cover how to configure Serilog to differentiate these options according to log...

DateTimeOffset vs DateTime in C#

DateTimeOffset vs DateTime in C#

C# offers many ways to handle date and time values. Due to the increase in the number of globalized applications all over the internet, it is paramount that dates and times of events are accurate and handled effectively. In this article, we will look at the...

Different Ways to Overwrite a File in C#

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...

How to Use onchange Event with Select DropDown in Blazor

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...

Techniques for Checking Floating-Point Equality in C#

Techniques for Checking Floating-Point Equality in C#

In this article, we will learn several techniques for checking floating-point numbers for equality. If we do not properly understand how floating-point values are stored internally, we might inadvertently write floating-point equality checks that do not behave as...

How to Use Stopwatch in C#

How to Use Stopwatch in C#

As software engineers, we know system precision and performance are essential, and the ability to measure time can come in handy to achieve this goal. That's where functionalities to capture and analyze time intervals can come in handy. We can leverage this to achieve...

Using HttpContext.Items to Pass Data With ASP.NET Core

Using HttpContext.Items to Pass Data With ASP.NET Core

In this article, we discuss how to leverage HttpContext.Items to preserve data in a request with ASP.NET Core. We can take advantage of this property to improve the efficiency of our applications. [sc name="github"...

File-Scoped Types in C# 11

File-Scoped Types in C# 11

The advent of C# 11 has brought with it a host of new features designed to improve and streamline the language's functionality. One of these enhancements is the introduction of file-scoped types, a unique concept designed to prevent name collisions among types,...

How to Use Basic Authentication With HttpClient?

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...

Differences Between Any and Exists Methods in C#

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. [sc...

How to Hide an Endpoint in Swagger

How to Hide an Endpoint in Swagger

When developing APIs, it is common to come across scenarios where we need to hide an endpoint from the public. In this article, we will explore various methods to achieve this goal, focusing on the Swashbuckle library in an ASP.NET application. [sc name="github"...

Difference Between String, FormattableString, IFormattable in C#

Difference Between String, FormattableString, IFormattable in C#

C# provides different ways of manipulating strings, which can be helpful when designing and implementing systems. So, in this article, we will delve deep into the distinctions among String, FormattableString, and IFormattable in C#. Besides that, we will test whether...