Why is ForEach Iteration over List<T> faster than IList<T>

In this post, I would like to draw your attention to the performance implications when iterating over IList<T> and List<T> . First let us begin by writing some code to run our benchmark tests against. We will execute a simple foreach loop against IList<T> and List<T>. [Benchmark] [ArgumentsSource(nameof(IListCollection))] public void ForEachIList(IList<int> collection) { foreach (var item in collection) { DoSomething(item); } } … Continue reading Why is ForEach Iteration over List<T> faster than IList<T>

MongoDb, Docker and Compass

The other day I struggled a bit in setting up MongoDb in a docker container and then connecting it with Compass - the MongoDb client. That's when I thought I would document the knowledge here so that anyone else who run into similar problems could look into it (and also in case I forget later, … Continue reading MongoDb, Docker and Compass

Exploring ‘With’ C# 10

C# 9 introduced us to record and the associated with operator. The with operator helped us to create or clone copies of existing record instances with set of changes specified. In C# 10, the C# team has taken the concepts a little further. Let us first examine what we could do in C# 9. public record Person { public string FirstName … Continue reading Exploring ‘With’ C# 10

.Net 6 : PeriodTimer

.NET supports various timer classes, each of which offers different functionality. As Microsoft states in its documentation, System.Timers.Timer, which fires an event and executes the code in one or more event sinks at regular intervals. The class is intended for use as a server-based or service component in a multithreaded environment; it has no user … Continue reading .Net 6 : PeriodTimer

Caliburn Micro 4.0 – Issue with EventAggregator

I have always like Caliburn Micro since I started using few years back. Of course had the opportunity to use it at work as well and that made it more likeable. But at the same time, I am not a huge fan of one of the latest changes that happened in v4.0, even though I … Continue reading Caliburn Micro 4.0 – Issue with EventAggregator

.Net 6 : ArgumentNullException.ThrowIfNull

.Net 6 has some nice little hidden features which helps in creating cleaner code, and in this post we will look into one such feature. Previously, if we needed to check if an object is null and raise an exception, we would have done as the following. void Foo(Bar bar) { if (bar is null) … Continue reading .Net 6 : ArgumentNullException.ThrowIfNull

Source Generator for DebuggerDisplayAttribute

While Debugging your application, it is often handy to have the DebuggerDisplayAttribute set, enabling you to quickly glance over complex data structures. While these aren't way too much to type in your self, it would be handy to have the code Auto generated for you. In this blog post, we will create a Source Generator using the … Continue reading Source Generator for DebuggerDisplayAttribute

WPF Tips and Tricks 001: TargetNullValue and FallBackValue

In this series of WPF Tips and Tricks we will cover smaller but useful WPF features which would help in making our applications better. n this first part of WPF Tricks,we will examine two often ignored and less frequently properties of Binding class - TargetNullValue and FallBackValue. TargetNullValue Consider the following View and ViewModel. View … Continue reading WPF Tips and Tricks 001: TargetNullValue and FallBackValue

Json To Xml : Wrapping the Array Elements

In this post, we will look into a scenario when you need to convert a Json to XML, but at the same time need to add a wrapping Property for each array. For example, consider the following Json { reportId : 23232, submittedBy : 'Anu Viswan', projects:[ { id:1001, name:'Project 1', }, { id:1002, name:'Project … Continue reading Json To Xml : Wrapping the Array Elements