If I have a IDictionary<int, int>, is it possible to receive a IEnumerable<int>, which
would contain every KeyValuePair<int, int> disassembled into two (int, int) entries inserted one after another?
Small example:
Dictionary:
5 - 25
6 - 36
7 - 49
Wanted Enumerable:
5, 25, 6, 36, 7, 49
Also, I wanted to have this in one super-pretty statement, but I couldn’t think of an appropriate one 🙂
Update:
Does LINQ allow to insert more than one element per .Select statement, something sharing the idea of:
xyz.Select(t => (t, null))
so that the resulting Enumerable would contain both t and null right after it?
You could use
SelectMany<TSource, TResult>(IEnumerable<TSource>, Func<TSource, IEnumerable<TResult>>)(plus overloads). Here’s an exampleAs per the comments, this is just one way of achieving what you have asked.