.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

C# 8 : Nullable Reference Types, Null Forgiving and Null Coalescing Assignment

There are some properties that ought to be learned together to understand the complete picture. In this blog post, we will address two of such features. Nullable Reference Types Let us begin by writing some code. public class Foo { public Bar Bar { get; set; } } public class Bar { public int Id … Continue reading C# 8 : Nullable Reference Types, Null Forgiving and Null Coalescing Assignment

Evil Code #010 : Extension Methods

Back with Evil Code Series again. What would be the output of the following. The code attempts to prints 2 set of data, "SampleText" and Null Value. The PrintToString method, prints the output from the inbuild ToString() method, while the second method PrintToDescription, prints the output from an extension method. The extension method, as such, … Continue reading Evil Code #010 : Extension Methods