Прочетете на английски

Споделяне чрез


ServiceProvider.GetRequiredKeyedService(Type, Object) Method

Definition

Gets the service object of the specified type.

C#
public object GetRequiredKeyedService(Type serviceType, object? serviceKey);

Parameters

serviceType
Type

The type of the service to get.

serviceKey
Object

The key of the service to get.

Returns

The keyed service.

Implements

Exceptions

The service wasn't found.

Applies to

Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)