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 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

Using declarations in C#8+ can allow us to dispose of resources correctly without increasing nesting levels

Since C#8 we can use single line using declarations which will allow us to dispose of resources at the end of the enclosing scope. This helps us reduce nesting in our code BUT… … while the using {} approach allows us to explicitly tell the compiler when to dispose of a resource, the C#8+ using declaration … Continue reading Using declarations in C#8+ can allow us to dispose of resources correctly without increasing nesting levels