I recently discovered the [FromServices] attribute, which has been a part of .Net Core since the first version. The [FromServices] attribute allows method level dependency injection in Asp.Net Core controllers. Here’s an example: Why use method injection over constructor injection? The common explanation is when a method needs dependencies and it’s not used anywhere else,…
Month: November 2019
C# 8 – Nullable Reference Types
Microsoft is adding a new feature to C# 8 called Nullable Reference Types. Which at first, is confusing because all reference types are nullable… so how this different? Going forward, if the feature is enabled, references types are non-nullable, unless you explicitly notate them as nullable. Let me explain. Nullable Reference Types When Nullable Reference…