Static methods in a static class, with this on the first parameter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // ====================================================================== // Q: What are extension methods? Where does .NET use them? // // Static methods in a static class, with this on the first parameter. They add // methods to types without modifying them. All of LINQ is extension methods, as // are all the builder.Services.AddXxx() calls. C# 14 also has extension members // (extension(...) blocks with properties). // ====================================================================== public static class DependencyInjection { public static IServiceCollection AddApplication(this IServiceCollection services) { services.AddScoped<PlaceOrderHandler>(); return services; // fluent: builder.Services.AddApplication().AddInfrastructure() } } |