TimeSpan in C#
Creating robust applications and solutions that can stand the test of time requires using complex dates and timespans to ensure accuracy. C# offers a robust TimeSpan structure that allows developers to easily manipulate dates, durations, and ranges. In this article,...
Return Multiple Values to a Method Caller In C#
In this article, we will learn and implement five different ways to return multiple values from a C# method. Returning multiple values to a...
How to Read Connection Strings in .NET
 In this article, we will learn how to read database connection strings from different configuration sources in .NET applications. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/aspnetcore-features/HowToReadConnectionStringsInDotNet"...
Code Maze Weekly #163
Issue #163 of the Code Maze weekly. Check out what's new this week and enjoy the read. We've added one more section to the weekly newsletter, the "Youtube Shorts". Let us know if you like this addition and if it's interesting/helpful to you. [sc name="writeforus"...
How to Read and Parse a JSON File in C#
When we develop software applications, we use JSON (JavaScript Object Notation) as a data interchange format, therefore we need to understand how to read and parse JSON files. In this article, we are going to explore six distinct ways to read and parse a JSON file in...
IEnumerable, ICollection, IList and List – Which One To Use?
In this article, we will learn about IEnumerable, ICollection, IList, and List. We will also focus on how to choose the right one. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/collections-csharp/IEnumerableVsICollectionVsIListVsList"...
Difference Between Returning and Awaiting a Task in C#
In this article, we are going to talk about the difference between returning and awaiting a Task in an async method in C#. The async/await...
How to Improve Enums With the SmartEnum Library
This article will look deeper into Enums in .NET and how we can improve them with the SmartEnum library. Let's begin! What Are Enums? Enumeration...
Convert a File to a Byte Array in C#
In this article, we will learn about situations where we may need to convert a file into a byte array. Additionally, we will learn two ways to perform the conversion in C#. If you want to learn how to convert a byte array to a file, check out our convert byte array to...
Code Maze Weekly #162
Issue #162 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Using Hangfire with ASP.NET Core [damienbod.com] Hangfire is a very popular open-source library for performing background...
Different Types of Comments in C# and Should We Use Them
In this article, we are going to talk about different types of comments in C#. The compiler will compile any syntactically correct code into an intermediate language, and after that, the .NET runtime will execute this IL code on the client computer. The computer will...
Passing Output Parameters to Stored Procedures with Dapper in C#
In this article, we are going to learn about passing output parameters to stored procedures with Dapper. Stored procedures are a great way to improve the performance, security, and usability of our code. They bring many advantages over relying on our application code...
Resolving the Call Is Ambiguous Error While Using LINQ
In this article, we will learn when the "call is ambiguous" error happens, why the error happens, and how to work around the issue. There are still so many legacy projects using older versions of EF Core, and in those projects, this error can cause a lot of headaches...
Create Clean Guard Clauses With GuardClauses in C#
In this article, we discuss how to create guard clauses, how they differ from user input validation, and how to improve our guards by writing clean guard clauses leveraging the GuardClauses library. [sc name="github"...
How to Compare Two Json Objects Using C#
In this article, we will be learning how to compare two JSON objects in C#. Let's dive in. Data Preparation For this article, we will be using a...
File and FileInfo Class Comparation in C#
In this article, we will look at the power of the File and FileInfo classes used for file manipulation in C#. We'll uncover the similarities and differences between these two classes and why we would want to use one over the other. [sc name="github"...
Code Maze Weekly #161
Issue #161 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Prevent accidental disclosure of configuration secrets [www.meziantou.net] Sometimes passwords can end up being exposed even if...
How to Modify a Base URI of Swagger in ASP.NET Core
In this article, we’re going to learn how to change Swagger base uri in ASP.NET Core Web API. So let's start. Swagger and Base Uri Swagger is an...
Determine Whether Two Date Ranges Overlap in C#
In this article, we will discuss how to determine whether two date ranges overlap in C#. We will explore how to achieve this result using the DateOnly and TimeOnly records and then, we're going to beautify our implementation with a custom class representing date...
Multipart Form-Data in HttpClient with ASP.NET Core
In this article, we will learn what multipart requests are and how we can use them. Also, we will review examples of how to send data to remote servers using multipart form-data with HttpClient in ASP.NET Core. [sc name="github"...
How to Get Formatted JSON in .Net Using C#
This article will examine how we can get a formatted JSON representation of our C# objects using two popular libraries - Json.NET and System.Text.Json. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/json-csharp/HowToGetFormattedJson"...