Something like that:
var distinct = dictionary.Values.SelectMany(x => x) .Distinct();
I decided to leave this answer, despite the fact that Mark has an equivalent - it is instructive to see both approaches. In my approach, we take a sequence of values ββ- each of which is an IEnumerable<Control> and smooths it, saying: "For each value, we want to get an IEnumerable<Control> , just by taking this vaula."
The Marc approach takes a sequence of key / value pairs and aligns what it says: "For each pair, we want to get an IEnumerable<Control> by taking the value of the pair."
In both cases, SelectMany takes a sequence of sequences of results and aligns them into one sequence, so the result before calling Distinct() is actually a sequence { contents, building, view1, contents, view2, building, view3 } . After that, calling Distinct will give the sequence { contents, building, view1, view2, view3 } .
source share