Flattening nested dictionaries with LINQ
问题 So I have a dictionary of the form Dictionary<int, Dictionary<int, Object>> myObjects and I would like to flatten this to a List<Object> flattenedObjects as simply as possible. I tried to come up with a clever solution, but so far all I've gotten to work is a solution with two nested foreach -loops that iterate over all of the elements, but I suppose there should be a nicer way of accomplishing this with LINQ. 回答1: try this List<Object> flattenedObjects = myObjects.Values.SelectMany(myObject