Grouping an IEnumerable based on multiple fields of the target type
I have an object Foo like this:
Given a
List<Foo>
, I'd like to group them into some kind of collection based on whether these fields are true or not. An item would appear in multiple lists if multiple of these are true.
I am currently thinking along these lines:
It feels like I should be able to do this more neatly with GroupBy or something, but I've only used that with single values before. Anyone done this?1 Reply
maybe something like this?
the
Generate(Foo f)
function could be a method of the class Foo
too
not as pretty as i would like, though :/
alternatively add a function returning all keys to Foo
:
and group like this: