Looks like Microsoft have pulled the null check !! operator from C#11. It had been included in C# 11 early previews. I can’t say I’m particularly unhappy about it. It has been discussed for years. Time to focus on more needed features I think. What do you think?
Author: csharp.academy
C# – LINQ GroupBy Examples
GroupBy is a LINQ functionality which allows to group items from a collection based on a given key. It’s an equivalent to SQL’s GROUP BY clause. In this article we’ll show various examples of usage, starting from the simplest grouping by one key, through grouping by multiple keys, custom result selector and all of that … Continue reading C# – LINQ GroupBy Examples
C# – LINQ Join Examples
Join is a LINQ functionality to combine two collections and produce a single result set. Connection happens by comparing items from both series. When there is a match then such pair is one of the output elements. Let’s consider following example. We’ve got two separate collections: countries and cities, which store objects of Country and … Continue reading C# – LINQ Join Examples
C# – How to generate random password
This article delivers proposal of algorithm to generate random passwords or actually random strings which are generated in safe manner and can be used as passwords, discount codes etc. Also, it is configurable, so that you can easily define expected length of string, pool of available characters or minimal number of occurrences of particular elements. … Continue reading C# – How to generate random password
C# – How to generate random string
There are situations where you need a random string which is built with specific characters. In this article you’ll see how to generate such string where both length and elements are totally up to you. Algorithm is very simple. It uses for loop, so that in every iteration it extends an output string with randomly … Continue reading C# – How to generate random string
C# – How to generate random number
Generating random numbers in C# is quick and easy using Random class. It’s built-in functionality which allows to produce integers, doubles and bytes. In this article you can find examples how to use it. Random integers The most basic usage is calling Next function without any parameters against an object of Random class. It returns … Continue reading C# – How to generate random number
C# – How to get unique items from list
The easiest way of getting unique items from list is LINQ’s Distinct() method. In this article you’ll see how to use it with both built-in types (like collection of integers) and custom types (like collection of complex type objects). Get unique values from collection of integers Let’s start with creating example list of items where … Continue reading C# – How to get unique items from list
.NET 6 performance improvements when comparing two arrays using SequenceEquals
There’s some pretty impressive performance improvements in .NET 6 when we are comparing arrays using the LINQ SequenceEqual method. The benchmarks below show that on my machine comparing two int arrays of 10K elements was 94 times faster in .NET 6 compared to .NET 5. We can see that there is also impressive improvements when … Continue reading .NET 6 performance improvements when comparing two arrays using SequenceEquals
Amazing performance improvement in .NET 6 when creating one SortedDictionary from another
The performance improvements when cloning one SortedDictionary from another in .NET 6 compared to .NET 5 are amazing. I’m not sure how commonly devs need to clone a SortedDictionary but on my machine .NET 6 can do this over 25 times faster than .NET 5 so this will definitely help some apps. Click on the image … Continue reading Amazing performance improvement in .NET 6 when creating one SortedDictionary from another
ImmutableList performance improvements in .NET 6
Another small but welcome performance improvement in .NET 6 is with item retrieval times when using ImmutableList… It looks like this performance boost is achieved by removing duplicate and unnecessary range checks.