Skip to main content
Extension methods providing a functional approach to null handling, inspired by Option/Maybe types.

Overview

Instead of nested null checks, use fluent transformations:

Transformation

Select

Transform a nullable value:

SelectMany

Transform with a selector that also returns nullable (flattens the result):

Filtering

Where

Keep the value only if it satisfies a predicate:

Side Effects

Do

Execute an action if not null, then continue the chain:

Default Values

Or

Return the value or a default:

OrElse

Return the value or compute a default lazily:

OrThrow

Return the value or throw an exception:

Pattern Matching

Match

Handle both cases explicitly:

Collection Conversion

ToEnumerable

Convert a nullable to a single-element or empty sequence:

Utility Methods

HasValue

Check if a reference type is not null:

NullIf

Convert sentinel values to null:

Examples

Safe Navigation

Configuration with Defaults

Validation Pipeline

Combining with LINQ

API Reference

Transformation

Filtering

Side Effects

Default Values

Pattern Matching

Utilities