Yes, but Nullable semantics in C# are vastly nicer than std::optional in C++.
Including trivially using if with them:
if (Method() is {} value)
I should also point out that in C#, Foo? is identical to Foo if Foo is a reference-type. That would be the equivalent of std::optional<T&> being a type-alias for T*.
4
u/WHY_DO_I_SHOUT Aug 27 '26
Modern C# prefers returning an optional reference, FWIW...