How to Serialize a Dictionary to JSON in C#
Resource-Based Authorization in ASP.NET Core
When authorizing requests in ASP.NET Core Web API projects, it's not enough to know the endpoint and the user; we also need to be aware of the specific resource the user is trying to access. In this article, we will learn how to tackle these situations using...
Property Ordering in C# JSON Serialization
In this article, we are going to learn how to perform property ordering within JSON serialization using the two most famous JSON libraries for .NET. The libraries are System.Text.Json, which has been natively available in the framework since .NET Core 3.0, and...
Aggregate Design in .NET
In this article, we will learn what is an aggregate in Domain-Driven Design. We will get to know which are the main design principles behind it. We will, also, design and implement a simple use case using these principles and learn how to organize business logic and...
Code Maze Weekly #169
Issue #169 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Static Fields Are Evil, If Not Coded Correctly [dotnettips.wordpress.com] A very important article about static fields and how they can affect our code by...
Different Ways to Split a String in C#
In this article, we will cover different ways to split a string in C#. As developers, we might often need to split strings into smaller substrings based on certain delimiters. C# provides us with the Split method, which is part of the String class. 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. [sc name="github"...