Class Predicates
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
elementT?The nullable struct object.
Returns
Type Parameters
TThe type of the struct.
False<T>(T)
Always returns false.
public static bool False<T>(T _)
Parameters
_TThe element.
Returns
Type Parameters
TThe 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
elementT?The nullable struct object.
Returns
Type Parameters
TThe type of the struct.
NotEmpty(string?)
Determines whether the provided string is neither null nor empty.
public static bool NotEmpty(string? s)
Parameters
sstringThe string.
Returns
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
sstringThe string.
Returns
- bool
true when
sis 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
elementTThe element.
Returns
Type Parameters
TThe 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
elementTThe element.
Returns
Type Parameters
TThe 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
_TThe element.
Returns
Type Parameters
TThe type of the element.