How to Register Services for Different Environments in .NET
In this article, we are going to learn how to register services for different environments in .NET. Let's start. Reasons to...
Code Maze Weekly #124
Issue #124 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Copying a collection: ToList vs ToArray [www.meziantou.net] ToList vs ToArray, which one is faster? Find out by reading this piece by Gérald Barré. IEnumerable...
How to Create a Comma-Separated String From a List of Strings in C#
In this article, we are going to learn how to create a comma-separated string from a list of strings in C#. Let's dive...
Copy To Clipboard in Blazor WebAssembly
In this article, we are going to learn how we can Copy to Clipboard in a Blazor WebAssembly Project. Let's start. How to Copy to Clipboard in...
Central Package Management for .NET Projects
Nowadays, every non-trivial software project depends on a number of external dependencies. Good software design is all about modularity, and that's one of the reasons behind NuGet's success in the .NET world. NuGet is the famous, well-integrated package manager for...
Implementing API Gateway with Ocelot in ASP.NET Core
In this article, we are going to learn how to implement an API Gateway using Ocelot. Ocelot is an open-source API Gateway, designed for microservices architecture. We already have an article about API Gateway, where we explained a lot about this subject. So, if you...
Code Maze Weekly #123
Issue #123 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Raw String Literals In C# 11 [dotnetcoretutorials.com] C# 11 brings us something new and convenient when working with strings. Let's find out what it is with Wade...
How to Convert JSON to XML or XML to JSON in C#
In this article, we are going to learn how to convert JSON to XML and XML to JSON in C#. We are going to explore how we can do such conversions...
Using the when Keyword in C# While Handling Exceptions
In this article, we are going to learn why and how to use the when keyword within try-catch blocks while handling exceptions in C#. We cannot avoid the occurrence of exceptions in the life cycle of an application. An exception is a problem that appears unexpectedly...
How to Read Data From a CSV File in C#
Reading from a CSV file in C# is a common operation. In this article, we are going to show how to easily read data from a CSV file in C# using the CSVHelper NuGet package. To download the source code for this article, you can visit our GitHub...
Check if a Number is a Power of 2 in C#
In this article, we are going to learn the most efficient and popular solutions to a very common problem - checking if a number is a power of 2. While it seems an easy task, we will see that some of these solutions are faulty in presence of corner cases. [sc...
Copy the Entire Contents of a Directory in C#
In .NET, there is no built-in way to copy the entire contents of a directory including subfolders and their content. In this article, we will explore a clean, platform-agnostic solution for this operation. Additionally, we will see how we can implement this in the...
Code Maze Weekly #122
Issue #122 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Getting telemetry data from inside or outside a .NET application [www.meziantou.net] Let's learn how to get logs, traces, and metrics using "dotnet trace", the...
How to Return HTML From ASP.NET Core Web API
A typical web API returns JSON or XML responses. However, rare cases exist where we need to return responses in other formats. In this article, we are going to learn how to return HTML from ASP.NET Core Web API. We will also state some use cases for this type of API....
Sorting and Filtering With LINQ
In this article, we are going to learn about Sorting and Filtering with LINQ. The Language-Integrated Query (LINQ) provides a robust set of language extensions that we can use to shape query results according to our current needs. LINQ not only allows for a type-safe...
Set C# Language Version for All the Projects in a Solution
C# language is actively developed. This means that from time to time a new version of the language is released. New versions give us access to recently added features and syntactic sugar. The default choice of the version depends on the target framework of the...
How to Add Multiple POST Actions in ASP.NET Core Web API
In this article, we are going to see how to add multiple POST actions to our Web API controller. For the demonstration, we are going to use the .Net 6 Web API project. [sc name="github"...
Introduction to Google Charts With Angular and ASP.NET Core Web API
In this article, we are going to look at using charts with Angular and ASP.NET Core Web API to visualize the relationship between data. We'll use Google Charts to create the visualization. It is a Javascript-based library used for data charting and visualization. We...
Code Maze Weekly #121
Issue #121 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Using User Secrets Configuration In .NET [dotnetcoretutorials.com] User secrets are a convenient way to store your sensitive information while developing the...
Priority Queue in C#
Priority Queue in C# is a very useful data structure that has so many real-world applications. In this article, we are going to cover the main concepts of Priority Queue in C#. We have covered the basic Queue in C#, it is recommended to check it out before continuing...
Long-Running Tasks in a Monolith ASP.NET Core Application
Often we come across scenarios where invoking a Web API endpoint triggers long-running tasks. In this article, we're going to explore the different ways we can implement such a long-running task in an ASP.NET Core Web API. [sc name="github"...