Table of Contents

Class Predicates

Namespace
Garyon.Functions
Assembly
Garyon.dll

Contains functions that can be used as predicates in functions that filter collections. Using these functions is advised over lambdas, as lambdas create a new delegate instance, effectively reducing performance.

public static class Predicates
Inheritance
Predicates
Inherited Members

Methods

DoesNotHaveValue<T>(T?)

Determines whether the provided nullable struct object does not have a value.

public static bool DoesNotHaveValue<T>(T? element) where T : struct

Parameters

element T?

The nullable struct object.

Returns

bool

The value opposite to HasValue for the provided object.

Type Parameters

T

The type of the struct.

False<T>(T)

Always returns false.

public static bool False<T>(T _)

Parameters

_ T

The element.

Returns

bool

Always false.

Type Parameters

T

The type of the element.

HasValue<T>(T?)

Determines whether the provided nullable struct object has a value.

public static bool HasValue<T>(T? element) where T : struct

Parameters

element T?

The nullable struct object.

Returns

bool

The value equal to HasValue for the provided object.

Type Parameters

T

The type of the struct.

NotEmpty(string?)

Determines whether the provided string is neither null nor empty.

public static bool NotEmpty(string? s)

Parameters

s string

The string.

Returns

bool

true when s is not null and has a non-zero length; otherwise false.

Remarks

Equivalent to !string.IsNullOrEmpty(s).

NotEmptyOrWhitespace(string?)

Determines whether the provided string is neither null, empty, nor consists exclusively of whitespace.

public static bool NotEmptyOrWhitespace(string? s)

Parameters

s string

The string.

Returns

bool

true when s is not null, not empty, and contains at least one non-whitespace character; otherwise false.

Remarks

Equivalent to !string.IsNullOrWhiteSpace(s).

NotNull<T>(T)

Determines whether the provided element is not null.

public static bool NotNull<T>(T element)

Parameters

element T

The element.

Returns

bool

true if the element is not null, otherwise false.

Type Parameters

T

The type of the element.

Remarks

For nullable structs, consider using HasValue<T>(T?).

Null<T>(T)

Determines whether the provided element is null.

public static bool Null<T>(T element)

Parameters

element T

The element.

Returns

bool

true if the element is null, otherwise false.

Type Parameters

T

The type of the element.

Remarks

For nullable structs, consider using DoesNotHaveValue<T>(T?).

True<T>(T)

Always returns true.

public static bool True<T>(T _)

Parameters

_ T

The element.

Returns

bool

Always true.

Type Parameters

T

The type of the element.