Container.GetService(Type) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the service object of the specified type, if it is available.
protected:
virtual System::Object ^ GetService(Type ^ service);
protected virtual object GetService (Type service);
protected virtual object? GetService (Type service);
abstract member GetService : Type -> obj
override this.GetService : Type -> obj
Protected Overridable Function GetService (service As Type) As Object
Parameters
Returns
An Object implementing the requested service, or null
if the service cannot be resolved.
Remarks
The default implementation of this method returns the current instance of the class if service
is an IContainer; otherwise, it returns null
. You can override this method to provide a custom implementation to return a service object. For more information, see the IServiceProvider.GetService method.