[This is preliminary documentation and is subject to change.]
Checks the value for null and throws exception if it is.
The method is useful for .ctor call chaining to preclude otherwise anonymous NullReferenceException
Namespace: NFXAssembly: NFX (in NFX.dll) Version: 3.0.0.1 (3.0.0.1)
public static T NonNull<T>(
this T obj,
Func<Exception> error = null,
string text = null
)
where T : class
public static T NonNull<T>(
this T obj,
Func<Exception> error = null,
string text = null
)
where T : class
<ExtensionAttribute>
Public Shared Function NonNull(Of T As Class) (
obj As T,
Optional error As Func(Of Exception) = Nothing,
Optional text As String = Nothing
) As T
<ExtensionAttribute>
Public Shared Function NonNull(Of T As Class) (
obj As T,
Optional error As Func(Of Exception) = Nothing,
Optional text As String = Nothing
) As T
public:
[ExtensionAttribute]
generic<typename T>
where T : ref class
static T NonNull(
T obj,
Func<Exception^>^ error = nullptr,
String^ text = nullptr
)
public:
[ExtensionAttribute]
generic<typename T>
where T : ref class
static T NonNull(
T obj,
Func<Exception^>^ error = nullptr,
String^ text = nullptr
)
static member NonNull :
obj : 'T *
?error : Func<Exception> *
?text : string
(* Defaults:
let _error = defaultArg error null
let _text = defaultArg text null
*)
-> 'T when 'T : not struct
static member NonNull :
obj : 'T *
?error : Func<Exception> *
?text : string
(* Defaults:
let _error = defaultArg error null
let _text = defaultArg text null
*)
-> 'T when 'T : not struct
- T
Return Value
Type:
TUsage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type . 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).