ObjectExtensionsNewIfNullT Method
Creates a new instance of the specified type if the object reference is null.
Namespace: DevCase.Extensions.ObjectExtensionsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[EditorBrowsableAttribute(EditorBrowsableState.Always)]
public static T NewIfNull<T>(
this ref T refObject
)
where T : class
<ExtensionAttribute>
<EditorBrowsableAttribute(EditorBrowsableState.Always)>
Public Shared Function NewIfNull(Of T As Class) (
ByRef refObject As T
) As T
Dim refObject As T
Dim returnValue As T
returnValue = refObject.NewIfNull()
public:
[ExtensionAttribute]
[EditorBrowsableAttribute(EditorBrowsableState::Always)]
generic<typename T>
where T : ref class
static T NewIfNull(
T% refObject
)
[<ExtensionAttribute>]
[<EditorBrowsableAttribute(EditorBrowsableState.Always)>]
static member NewIfNull :
refObject : 'T byref -> 'T when 'T : not struct
No code example is currently available or this language may not be supported.
- refObject T
-
The object reference to check for null.
- T
-
The type of the object reference.
T
If the object reference is not null, returns the original object reference.
If the object reference is null,
creates a new instance of type
T and returns it.
In Visual Basic and C#, you can call this method as an instance method on any object of type
T. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).