Hidden gems in List Pattern

In this blog post, we will explore few hidden gems in list patterns , which was introduced with C# 11. List Pattern allows us to check patterns in arrays or list. Assign Variable You can assign variables using pattern, provided the pattern matches. For example, var arr = new [] {1,2,3,4,5}; if(arr is [_,2,var third,..] match) { … Continue reading Hidden gems in List Pattern


Compare JSON Arrays

How do you compare two similar JSON array set ? I bet that is a scenario you might have across atleast once in your developer life. Let us say you have following two sets of JSONs. Json Set 1 [ { "SourceLocation":"England", "DestinationLocation":"Spain", "DeliveryDate":"9/12" }, { "SourceLocation":"England", "DestinationLocation":"Germany", "DeliveryDate":"9/12" } ] Json Set 2 [ … Continue reading Compare JSON Arrays

The required modifier : Understand the limitations

C# 11 introduced the required modifier, which indicates that the applied peroperties and fields should be initialized by all available constructors or using object initializer. We learned more about the modifier in our earlier post. In this post, we take a look into a limitation of the functionality. Consider the following code. publicclassFoo { public required string Name {get;set;} public … Continue reading The required modifier : Understand the limitations

K-Sum – A generalized solution

In this blog post, we will attempt to address the 4-Sum problem from Leet code using the generic approach of K-Sum. Let us state the official definition of the problem. Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, … Continue reading K-Sum – A generalized solution

Generate Password Hash for RabbitMq

In the previous post, we explored how to use docker compose to per-initialize queues in a docker container. The configuration files also provided a way to initialize users. Each of the users where configured with a password, which is given in the configuration file as a hash value comprising of a randomly generated 32 bit salt and … Continue reading Generate Password Hash for RabbitMq

Circuit Breaker with Ocelot & Polly – Part 2

In the previous blog post on Circuit Breaker with Ocelot And Polly, we saw how we could use the Ocelot library's inbuilt support for Polly to build Circuit breakers for handling timeout errors from the downstream services. In this blog post, we will address, how we could trigger a circuit breaker when the downstream service returns … Continue reading Circuit Breaker with Ocelot & Polly – Part 2

Handling Cyclic References during Serialization

In the previous post, we discussed handling subtypes during protubuf serialization. In this post, we will continue with serialization and discuss the handling of cyclic references. We will look into how cyclic references could be addressed in 3 key types of serializations. JsonXmlProtobuf As an example of cyclic references, we will address the classic example … Continue reading Handling Cyclic References during Serialization

Implementing Mediator And CQRS in .Net 6 Web Api

In some of the previous posts, we visited the Mediator and CQRS patterns, understanding the benefits it brings to the table. In this blog post, we will look into implementing the Mediator and CQRS pattern in our .Net Core Web Api application. We would be using the Mediatr library by Jimmy Bogard for the implementation of the … Continue reading Implementing Mediator And CQRS in .Net 6 Web Api

A2Z.Net : B – BackgroundService

Long-running background processes have been a need for long and for over the years, this has been accomplished in various approaches in .Net. With the introduction of Worker Service templates, it has become a lot easier to create asynchronous long-running background tasks that are supported across platforms and have inbuilt capabilities like Dependency Injection. The … Continue reading A2Z.Net : B – BackgroundService