How to Use RabbitMQ in ASP.NET Core
In this article, we are going to take a look at using a message broker, RabbitMQ, with an ASP.NET Core Web API application. Message brokers are...
MY ARTICLES:
A foreach loop is how we iterate a Dictionary<TKey, TValue> in C#. Each pass hands us one KeyValuePair<TKey, TValue>, and the shortest way to read it is to deconstruct it in the loop header: foreach (var (key, value) in monthsInYear). To...
In this article, we are going to explain the core idea and basic concepts of the minimal APIs in .NET 6. But if we try to explain it in one sentence, it will be that it is an API without the need for a controller. Other than a theoretical explanation, we are going to...
A DateTime format string tells ToString() how to turn a date and time into text. There are two kinds. A standard specifier is a single character, such as "d", "O" or "u", that stands for a whole pattern the culture supplies. A custom format string is anything longer,...
x != y compares two values and runs any != overload the type defines. x is not ... matches a pattern instead: the right side must be a constant, a type or another pattern, and our type's overloads never run. For an int compared with a constant, both compile to the...
The code we write doesn't always work the way we want it to. It could be due to a syntactical error or a logical one. While the compiler generally points to the syntax-related errors and helps us fix them, logical errors aren't that straightforward. This is when we...
In this article, weβre going to learn about using RestSharp in a .NET project. RestSharp is an open-source HTTP Client library that we can use to consume APIs easily. RestSharp features automatic serialization and deserialization, request and response type...
In this article, we're going to talk about Rate Limiting in ASP.NET Core and explore some ways of implementing it. Let's dive into it. What Is Rate Limiting?...
One of the most commonly used collections in C# is a List collection. The List<T> class represents a collection of strongly typed objects, which we can access through their indexes. It has properties and methods for performing tasks such as adding, searching,...
To convert an int to a string in C#, we call ToString() on it: luckyNumber.ToString() turns the number 3 into the text "3". It is the most direct option and, in our .NET 10 benchmark, one of the fastest. int is an alias of the Int32 type, which represents a whole...
To set every element of a C# array to one value, we call Array.Fill(array, value). It writes the value into each element of an array we already have, in a single call. Enumerable.Repeat() and a plain for loop get the same result. We're going to explore these built-in...
C# converts a string to a bool with three methods, and all three accept exactly two strings: "true" and "false", in any casing, with leading and trailing white space ignored. "1", "0", "yes" and "" are not boolean text in .NET and none of them converts. [sc...
In this article, we are going to take a look at the different ways we can add Custom Headers to our ASP.NET Core Web API Responses. Custom Headers...
In this article, we are going to learn about operator overloading in C#. It gives us various flexibility when we work with user-defined types. Let's start. What...
In this article, we are going to create a minimal ASP.NET Core 6 Web API that supports the creation of multiple resources via a POST request. Network communication can be (or is) one of the bottlenecks in the microservice architecture, so creating multiple resources...
In this article, we are going to talk about a behavioral design pattern, the Observer Pattern. We are going to learn what problem this pattern solves and how we can implement it in C#. To download the source code for this article, you can visit our...
Arrays are data structures that help programmers store multiple values of a specific type in a single variable. We can use different techniques to initialize arrays in C#, and we are going to discuss them in this article. To download the source code...
A SortedList in C# is a collection of key-value pairs that must be sorted at any given point in time based on its keys. Whenever we add or remove an element, the list keeps the keys in order on its own, so we never have to sort it. We'll create both versions of the...
In this article, we are going to learn different techniques to find the maximum value of an array in C#. At the end of this article, we will do a performance benchmark to check which is the faster approach.Β To download the source code for this...
In this article, we are going to learn about the named arguments and optional parameters in C#. More importantly, we are going to see the use cases for both techniques and learn how to use them. To download the source code for this article, you can...