Code Maze Weekly #168
Issue #168 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Looking at C# 12 Proposals and Beyond [michaelscodingspot.com] Let's find out what C# has in store for us going forward. Let's take a look at features like...
Handling CommandTimeout With Dapper in .NET
In this article, we are going to learn how to handle CommandTimeout with Dapper in .NET. So, let’s start. About Dapper Dapper is a...
How to Declare an Empty Array in C#
In this article, we are going to look at the numerous ways to declare an empty array in C#. Arrays are used to store multiple variables of the same type. Sometimes our solution design may require the use of an empty array. For example, as an initial value for a...
How to Write Logs From Startup.cs/Program.cs in .NET
Why should we write logs from the startup of an application? Usually, we write logs from various application events and user interactions. These are to record what activities the user performs, what data the app deals with, etc. When something goes wrong with our...
How to Remove All Whitespace Characters From a String in C#?
In this article, we're going to look at removing all whitespace characters from a string in C#. Strings often have leading or trailing whitespace that we would like to remove, or we may even want to remove all whitespace in between. Let's take a look at several ways...
Refactoring Object-Orientation Abusers in C#
In this article, we are going to explore how to recognize and refactor a code smell called object-orientation abusers in C#. ...
Null-Conditional Operators in C#
In this article, we will discuss a feature of C# known as null-conditional operators and how it can help prevent the occurrence of null-reference exceptions, which are commonly encountered by developers. MAUI is a new technology and thus it's really fun to play around and develop with it. But what if...
How to Unit Test ILogger in ASP.NET Core
We commonly write unit tests to test the business logic of our application. But what about the times we also want to make sure our logging works as expected? In this article, we will cover both cases and learn how to unit test ILogger in ASP.NET Core applications. ...
Vendor-Agnostic Telemetry Using OpenTelemetry Collector in .NET
When building applications, we try to avoid being tightly coupled to any given third-party service/library, making it harder to switch this implementation with another in the future should the need arise. When working with OpenTelemetry in our applications, we can use...
How to Delete Elements from an Array in C#
In this article, we will explore several different ways to delete elements from an array in C# based on their value and compare their performance to help you choose the best option for your specific use case. An honest and insightful review of what Blazor brings us in .NET 8 by Damien...
How to Create a Custom JsonConverter in Json.NET
In this post, we are going to learn how to create a custom JsonConverter in Json.NET. Json.NET (aka Newtonsoft.Json) is widely popular for its...
The AddEndpointsApiExplorer Method in ASP.NET Core
In this article, we are going to learn about the AddEndpointsApiExplorer method in ASP.NET Core. We will learn why we need it and how we use it in our applications. For this article, we will use an ASP.NET Core Web API application with Swagger support. If you feel the...
Get Current User With Claims in ASP.NET Core
In this article, we are going to see different ways to get the currently authenticated user using claims in ASP.NET Core. The code for this article is based on the respective code from the article on Authentication with ASP.NET Core Web API. Async/Await and asynchronous programming are part of our lives for a...