LazyInitializer.EnsureInitialized<T> Method (T%, Boolean%, Object%)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Initializes a target reference or value type with its default constructor if it has not already been initialized.
Assembly: mscorlib (in mscorlib.dll)
public static T EnsureInitialized<T>( ref T target, ref bool initialized, ref Object syncLock )
Type Parameters
- T
The type of the reference to be initialized.
Parameters
- target
- Type:
T
%
A reference or value of type T to initialize if it has not already been initialized.
- initialized
- Type:
System.Boolean
%
A reference to a boolean that determines whether the target has already been initialized.
- syncLock
- Type:
System.Object
%
A reference to an object used as the mutually exclusive lock for initializing target. If syncLock is null (Nothing in Visual Basic), a new object will be instantiated.
Return Value
Type: TThe initialized value of type T.
| Exception | Condition |
|---|---|
| MemberAccessException | Permissions to access the constructor of type T were missing. |
| MissingMemberException | Type T does not have a default constructor. |
Show: