Why is enumerating over List faster than IList?
If we have a List<T>
and an IList<T>
, enumerating over the List<T>
is faster than enumerating over the IList<T>
. Why is that?
Hey, I'm Steven a .NET Developer in Switzerland. I am a Microsoft MVP. Also, this blog is open source on GitHub.
If we have a List<T>
and an IList<T>
, enumerating over the List<T>
is faster than enumerating over the IList<T>
. Why is that?
For good reasons, many folks don't want to use reflection. Since .NET 8, we have a better way of dealing with this in most of the cases (when known in advance). But we can go the opposite: Make it even unsafer for a tiny bit performance!
In C# we have many nice guards sitting on top of static exceptions classes like ArgumentNullException
, ArgumentOutOfRangeException
, etc: As ArgumentException.ThrowIfNullOrEmpty
, ArgumentException.ThrowIfNullOrWhiteSpace
. Now we can extend them easily!
NuGet can cache a lot of packages and other stuffs over time. Here a small rundown on how to clear the biggest chunk.
The dotnet documentation gets hints about using GitHub Copilot. Is this an ad? And can we expect more in the future?
New dotnet version means new features and improvements. There is a nice update to the HttpClient
class in .NET 10.
With the latest preview: .NET 10 preview 3, we did get an overhaul on extensions. It might enable some nice tricks in the future.
Sometimes you want to have a custom 404 page - and since .NET 8 and "Blazor WebApps" the <NotFound>
tag of the Router
doesn't work anymore, so let's create a custom page for that.
LinkedIn is never short on performance tips on .NET - And this time we drag the whole database towards the client, twice!
After some time, I updated my C# language mind map to the latest version: C# 14. Either as "poster" or clickable version!