I have a nullable boolean property of an object inside a list, I want to check if all are equal and return its value, and return null if there is a value that is not equal.
e.g.
Object1
string Name
bool? NullBool
Object1 is in list e.g. List<Object1> and I just need to check and return NullBool using Linq
I want to do something like
bool? returnVal = <my Linq / Function to get what I want>
Not pretty, but:
Now that’s pretty efficient because:
Additionally, it will work fine when the source-collection is empty.
For a list, you can also efficiently do: