StringHelper..::..IfNotNull<(Of <(<'T, TResult>)>)> Method

if the object this method is called on is not null, runs the given function and returns the value. if the object is null, returns default(TResult) var username = HttpContext.Current.IfNotNull( ctx => ctx.User.IfNotNull( user => user.Identity.IfNotNull( iden => iden.Name ) ) );

Namespace:  Core
Assembly:  Core (in Core.dll)

Syntax


public static TResult IfNotNull<T, TResult>(
	T target,
	Func<T, TResult> getValue
)

Type Parameters

T
TResult
The type of the result.

Parameters

target
Type: T
The target.
getValue
Type: Func<(Of <(<'T, TResult>)>)>
The get value.

Return Value

TResult.