I have a method that searches a list of objects based on some of the fields of the object. If a matching object is found, I return it, but I want to be able to represent a no-match situation. Normally I’d return null but I’m working with a non-nullable class I cannot change.
Share
There are several options. Use a
Nullable<T>, or return a bool and use anoutparameter to get the actual result, e.g.:Or: