英語で読む

次の方法で共有


ServiceProviderKeyedServiceExtensions.GetKeyedService<T> メソッド

定義

から 型 T のサービスを取得します IServiceProvider

C#
public static T? GetKeyedService<T> (this IServiceProvider provider, object? serviceKey);

型パラメーター

T

取得するサービス オブジェクトの型。

パラメーター

provider
IServiceProvider

サービス オブジェクトの取得元の IServiceProvider

serviceKey
Object

取得するサービス オブジェクトのキーを指定する オブジェクト。

戻り値

T

T のサービス オブジェクト。または null そのようなサービスがない場合は 。

適用対象

製品 バージョン
.NET 6, 7, 8, 9
.NET Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1