Get all the keys in Array of Dictionary

  • A+

I have an array of dictionaries as Follows:

Dictionary<int, int>[] matrix = new Dictionary<int, string>[10]; 

I need all the keys saved in this dictionary which I am using in a foreach loop as below:

 foreach (int key in matrix.Keys)   {    } 

Obviously, matrix.Keys won't work here. So,is there any way to get all the keys of dictionary without looping through the whole array (maybe Linq or something)?

 var allKeys = matrix.SelectMany(d => d.Keys);   foreach (int key in allKeys) ... 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: