Similar Posts
How to take a screenshot in .NET core
In this article we’re going to look at how you can grab a screenshot of your entire desktop – that means all your displays, not just the primary one – from a console application using .NET core. This solution relies on Windows-only dependencies, so it will not work cross-platform, it will only work on Windows….
What’s new in .NET 8
.NET 8 was released on November 14, 2023 as an LTS (Long Term Support) version, meaning it will continue to receive support, updates, and bug fixes for at least three years from its release date. As usual, .NET 8 brings support for a new version of the C# languange, namely C# 12. Check out our dedicated page…
System.Text.Json – How to modify existing type info resolver
There are some situations in which creating a whole new IJsonTypeInfoResolver will seem overkill, when the default (or any other already defined) type info serializer could do the job with only one or two small modifications. Until now, you could play with the DefaultJsonTypeInfoResolver.Modifiers property for the default type info resolver, but you didn’t have…

C# – How to mark features as experimental
Starting with C# 12, a new ExperimentalAttribute is introduced allowing you to mark types, methods, properties or assemblies as being experimental features. This will trigger a compiler warning during usage which can be disabled using a #pragma tag. The Experimental attribute requires a diagnosticId parameter to be passed in the constructor. That diagnostic ID will…
.NET 8 performance: 10x faster GetGenericTypeDefinition
.NET 8 brings some neat performance for existing APIs that handle type information. One such API that has seen a significant improvement is GetGenericTypeDefinition. In my benchmarks, the .NET 8 implementation is almost 10 times faster compared to the .NET 7 version. You can run this benchmark yourself if you’d like using BenchmarkDotNet: Or if…
C# Access private property backing field using Unsafe Accessor
One less-known feature of the UnsafeAccessorAttribute is that it also allows you to access auto-generated backing fields of auto-properties – fields with unspeakable names. The way to access them is very similar to accesing fields, the only difference being the member name pattern, which looks like this: Let’s take the following class as an example:…