Hey, I'm Steven a .NET Developer in Switzerland. I am a Microsoft MVP. Also, this blog is open source on GitHub.

Older Posts

Preview image blogpost

Structure and order your DI container

Does your Dependency Injection container is one big pile of method calls one after the other? Are there 50 lines of just AddScoped, AddTransient, and so on? Well, let's fix this.

We can utilize extension methods to make an order to that mess!

Read the whole article

Preview image blogpost

Array, List, Collection, Set, ReadOnlyList - what? A comprehensive and exhaustive list of collection-like types

.NET knows a big list of collection-like types like: IEnumerable, IQueryable, IList, ICollection, Array, ISet, ImmutableArray, ReadOnlyCollection, ReadOnlyList, and many more.

This blog post will give you an exhaustive list of types in .NET and when to use what.

Read the whole article

Preview image blogpost

Simple DI - Container

This blog post will show you a very simple Dependency Injection container.

This will give a better understanding of what Dependency Injection is and how it is done. And sure we will see how this is related to IoC - Inversion of Control.

Read the whole article

Preview image blogpost

Delete a record without prior loading in Entity Framework

Sometimes you have an Id of an object and want to delete the underlying thing from the database. But it doesn't make sense to load the whole object from the database to memory first. So how can we achieve this quickly?

Read the whole article

Preview image blogpost

ChatGPT - Current state for .NET - and in general

ChatGPT is going viral right now. Besides funny conversations, you can use that tool to generate also code for you. But does it really hold up to its reputation and it is a serious pairing partner? Let's see.

Read the whole article

Preview image blogpost

Check for elevated rights in .NET 8

In the past, it was tricky to get if the current process runs under elevated rights. In the sense of it is run under the sudo group in *nix (Unix, Linux, macOS, you name it) or administrative rights in Windows.

But that changes with .NET 8 as we now have a unified API for that.

Read the whole article

Preview image blogpost

Abstraction vs Encapsulation

Abstraction and Encapsulation are two fundamental concepts in object-oriented programming. So let us have a small look what the difference is between those two.

Read the whole article

Preview image blogpost

How to enumerate through a StringBuilder

Did you ever wonder how we can iterate through a StringBuilder? I mean, of course, we can just call ToString and use the returned string, but that means we materialize the whole thing without good reason.

We can also use a normal for-loop. But we can also find a completely different and probably dumber way! And if you wonder: No, this is not something you do in your daily life, but by doing so, I can show some cool stuff C# and .NET offer.

Read the whole article

Preview image blogpost

New ArgumentException and ArgumentOutOfRangeException helpers in .NET 8

Do you remember how .NET 6 introduced the ArgumentNullException.ThrowIfNull guard? And afterward, with .NET 7 we've got this excellent bit: ArgumentException.ThrowIfNullOrEmpty? Guess what, there might come some new handy additions for the upcoming .NET 8 iteration.

So let's see what are those new changes and how they make the code simpler.

Read the whole article

Preview image blogpost

A new wave of analyzers in .NET 8

Analyzers did become an integral part of the .NET ecosystem. Their main responsibility is to find potential code issues and warn you. Often times this comes even with potential fixes you can directly apply.

And Microsoft will continue this journey with the upcoming .NET 8 release. This blog post will show you potential candidates, which will make the cut.

Read the whole article

An error has occurred. This application may no longer respond until reloaded. Reload x