Method GetOrDefault
GetOrDefault<T>()
Gets a singleton previously defined in this context bag via its type T
.
Returns the default value if the object is not defined.
public T? GetOrDefault<T>() where T : notnull
Returns
- T
The object of type
T
if it exists; otherwise,null
.
Type Parameters
T
The type of the object defined in this context bag.