Generic Constraint for Non Nullable types
From C# 8.0 you can now use the where T : notnull
generic constraint to specificy T
is a non-nullable type.
Applying where T : struct
applies a generic constraint that T
be a non-nullable value type. Since there are no non-nullable reference types, this has the exact same semantics as simply "all non-nullable types". Nullable value types (i.e. Nullable<T>
) do not satisfy the struct
generic constraint.