I have a Dictionary that looks like such: Dictionary<Search_Requests, List<Tuple<Search_Subjects, SearchData>>>
In the SearchData
class, there's a property called SearchCode
. What I want to do is get an array of every search code that appears in this dictionary. I could do this with a few loops, but I'd really prefer to use LINQ. Unfortunately, I can't wrap my mind around how to do this. I tried
RequestDictionary.Select(s => s.Value.Select(z => s.Value.Select(x => x.Item2.SearchCode).ToArray()).ToArray()).ToArray();
But that just got me a string[][][]
, which isn't close to what I wanted. Can I get a push in the right direction?
You can use .SelectMany()
to flatten the results:
RequestDictionary
.SelectMany(s
=> s.Value.SelectMany(z => s.Value.Select(x => x.Item2.SearchCode))
.ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With