ServiceCollectionDescriptorExtensions.Replace Method

Definition

Removes the first service in IServiceCollection with the same service type as descriptor and adds descriptor to the collection.

C#
public static Microsoft.Extensions.DependencyInjection.IServiceCollection Replace(this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor);

Parameters

descriptor
ServiceDescriptor

The ServiceDescriptor to replace with.

Returns

The IServiceCollection for chaining.

Applies to

Producto Versiones
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)