title: Processing a C# Dictionary using LINQ
body: <p>How do I write the "// Display using Foreach" loop implementation using LINQ Lambda Expression / Statemene Expression? </p>
  
  <p>I want to simplify my development and avoid nested foreach loops as much as possible. I am trying to include more logic with in the second foreach statement and I want to use Lambda / Statement expression.</p>
  
  <pre><code> internal class Program
  {
      internal class Country
      {
          public string CountryName { get; set; }
          public int CountryCode { get; set; }
      }
      static void Main(string[] args)
      {
          List&lt;Country&gt; countries = new List&lt;Country&gt;()
          {
              new Country{CountryName = "India", CountryCode=1},
              new Country{CountryName = "Andaman Nicobar", CountryCode=1},
              new Country{CountryName = "United States of America",  CountryCode=2},
              new Country{CountryName = "Alaska",  CountryCode=2},
              new Country{CountryName = "Hawaii",  CountryCode=2},
              new Country{CountryName = "United Kingdom", CountryCode=3},
              new Country{CountryName = "Australia", CountryCode=4}
          };
  
          Dictionary&lt;int, List&lt;Country&gt;&gt; countriesDictionary = new Dictionary&lt;int, List&lt;Country&gt;&gt;();
          foreach (Country country in countries)
          {
              if (!countriesDictionary.ContainsKey(country.CountryCode))
                  countriesDictionary.Add(country.CountryCode, new List&lt;Country&gt;());
              countriesDictionary[country.CountryCode].Add(country);                
          }
  
         // Display using Foreach
  
          foreach (int key in countriesDictionary.Keys)
          {                             
              List&lt;Country&gt; dCountries = countriesDictionary[key];
  
              foreach (Country country in dCountries)
              {
                  if (country.CountryCode.Equals(key))
                  {
                      Console.WriteLine(country.CountryName);
                  }                
              }
              Console.WriteLine();            
          }
          Console.ReadLine();
      }
  </code></pre>
  
  <p>Please suggest.</p>