I am trying to return an element in a List (lookupData) that matches a specific criteria (as defined by the elements in the lookupKey array).
However, no result is returned if I define the output as IEnumerable type. The 'Output' variable resets at the final loop when i = 2 . Why does it not work?
I want to keep the output varaible as IEnumerable instead of List as it is more efficient.
   var lookupKey = new string[] { "Male", "China" };
   var lookupData = new List<string[]>();
   lookupData.Add(new string[] { "Male", "China" });
   lookupData.Add(new string[] { "Male", "America" });
   lookupData.Add(new string[] { "Female", "UK" });
   IEnumerable<string[]> output = lookupData;
   for (int i = 0; i < 2; i++)
   {
      output = output.Where(x => x[i] == lookupKey[i]);
   }
 
     
     
     
     
     
    