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. [sc name="patreon-source-code"...
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 a CSV File in C#
A CSV file is text, but it is not simple text. A field can hold a comma, a quote, or a line break, and any of the three breaks string.Split(','). CsvHelper reads all of them correctly and maps each row onto a class of ours. Three lines do the work: open a StreamReader...
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#
To copy a directory and all of its contents in C#, we first recreate its folder tree under the destination and then copy every file into it. System.IO has no method that does both, so we write a short helper ourselves. Then we'll turn the helper into an extension...
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 C#
LINQ sorts a sequence with OrderBy(), ThenBy(), Order() and their descending versions, and filters it with Where() and OfType<T>(). None of these operators changes the source collection. Each one returns a new sequence, and LINQ computes it only when we...
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"...
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...
Priority Queue in C#: How to Use the PriorityQueue Class
A priority queue in C# is the PriorityQueue<TElement, TPriority> class. Every element we enqueue carries a priority, and Dequeue() returns the element with the lowest priority value, not the one that arrived first. It has plenty of real-world uses, from hospital...
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"...
Introduction to Testing Blazor WebAssembly With bUnit
In this article, we are going to learn about unit testing a Blazor WebAssembly Project using the bUnit testing library. If you find some of the concepts we are testing hard to understand, we have a great Blazor WebAssembly Series that is worth checking out. [sc...
Distributed Caching in ASP.NET Core
In this article, we are going to learn what Distributed Caching is and how to implement distributed caching in an ASP.NET Core application. Let's...
Insertion Sort in C#
Insertion sort is a sorting algorithm that keeps a sorted part at the start of the array and inserts each next element into its place there, shifting the bigger ones one position to the right. We can write it in C# with two nested loops or with one recursive method,...
JSON Deserialization to a POCO Class in C#
Deserialization is the process of taking a string representation of an object and creating that object in memory. JSON is an ever-increasingly popular format to serialize objects into. It has become nearly ubiquitous in API communication. In this article, we will take...
Using the dotnet format Command and –verify-no-changes
dotnet format is the .NET SDK command that rewrites our C# code to match the rules in .editorconfig. With --verify-no-changes, it runs the same check without touching a file and exits with code 2 when anything would change. We'll go through the basic usage, why the...
Upload Files With Drag & Drop or Paste in Blazor
In this article, we are going to look at how we can upload files to a Blazor Server application using Drag & Drop, as well as Copy/Paste functionality. We will be making use of the JavaScript Interop to invoke JavaScript functions from our C# code. Therefore, we...










