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

.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

.Net 6 : Jwt Authentication in Minimal Web Api

In the previous post, we delved into Jwt Authentication implementation in the .Net Core 5. In this post, we will create a Minimal Web API (introduced in .Net 6) and implement Jwt Authentication in it. Minimal Web API allows developers to build low ceremony web apis without the overhead of ceremonial code in traditional Asp.Net core MVC … Continue reading .Net 6 : Jwt Authentication in Minimal Web Api

.Net 6: Linq enhancements

Linq has got some noticeably enhancements in the .Net 6. In this post, we will briefly visit some of them. Specify Default Value for FirstOrDefault, LastOrDefault, SingleOrDefault One of the features I am so relieved to see if the support for specifying default value for FirstOrDefault(), LastOrDefault(), and SingleOrDefault(). I never quite understood why it wasn't included in … Continue reading .Net 6: Linq enhancements

.Net 6 : Benchmark performance of JsonSerializer.DeserializeAsyncEnumerable

This should have been part of my earlier post on System.Text.Json Support for IAsyncEnumerable, but it slipped off my mind. So here we are. To understand the significance of this feature in .Net 6, one need to understand the circumstances under which these might be useful. The first of those would be of course, that the … Continue reading .Net 6 : Benchmark performance of JsonSerializer.DeserializeAsyncEnumerable

.Net 6 : System.Text.Json support for IAsyncEnumerable

As the Preview 4 of .Net 6 becomes available, one of the things that excites me is the System.Text.Json support for IAsyncEnumerable. The IAsyncEnumerable, introduced in .Net Core 3 and C# 8, enables us to iterate over async Enumerables. The newer version extends this support to the System.Text.Json. Consider the following data. [{"Id":0,"Value":"915777539"},{"Id":1,"Value":"1332243482"},{"Id":2,"Value":"306207588"}, {"Id":3,"Value":"1413388423"},{"Id":4,"Value":"2145941621"},{"Id":5,"Value":"1041779876"}, {"Id":6,"Value":"1121436961"},{"Id":7,"Value":"520045044"},{"Id":8,"Value":"1357859915"}, {"Id":9,"Value":"1340510964"},{"Id":10,"Value":"1183306988"},{"Id":11,"Value":"502467538"}, {"Id":12,"Value":"31513434"},{"Id":13,"Value":"999086707"},{"Id":14,"Value":"961728759"}, {"Id":15,"Value":"1756662810"},{"Id":16,"Value":"1018107007"},{"Id":17,"Value":"433502262"}, {"Id":18,"Value":"1784715926"},{"Id":19,"Value":"1418088822"},{"Id":20,"Value":"645106286"}, {"Id":21,"Value":"1720929044"},{"Id":22,"Value":"1102142546"},{"Id":23,"Value":"2138442183"}, {"Id":24,"Value":"208176799"},{"Id":25,"Value":"1700100438"},{"Id":26,"Value":"769308703"}, … Continue reading .Net 6 : System.Text.Json support for IAsyncEnumerable