Ioc.GetService 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.
Overloads
GetService(Type) | |
GetService<T>() |
Tries to resolve an instance of a specified service type. |
GetService(Type)
public object? GetService (Type serviceType);
abstract member GetService : Type -> obj
override this.GetService : Type -> obj
Public Function GetService (serviceType As Type) As Object
Parameters
- serviceType
- Type
Returns
Implements
Applies to
GetService<T>()
Tries to resolve an instance of a specified service type.
public T? GetService<T> () where T : class;
member this.GetService : unit -> 'T (requires 'T : null)
Public Function GetService(Of T As Class) () As T
Type Parameters
- T
The type of service to resolve.
Returns
T
An instance of the specified service, or null
.
Exceptions
Throw if the current Ioc instance has not been initialized.