title: How to write Dictionary contents to a textfile
body: <p>I have declared a dictionary like below--</p>
  
  <pre><code>Dictionary&lt;int, string&gt; dic = new Dictionary&lt;int, string&gt;()
  {
         {977,"String1"}, 
         {1021,"String2"},
         {784,"String3"},
         {801, "String4"}
  };
  </code></pre>
  
  <p>In my textfile value will be contain like this-</p>
  
  <pre><code>977,"String1", 
  1021,"String2",
  784,"String3",
  801, "String4"
  </code></pre>
  
  <p>I want to store above dictionary keys and values manually in a text file and want to access like dictionary by for loop. </p>
  
  <p>Like this--</p>
  
  <pre><code>foreach (KeyValuePair&lt;int, string&gt; pair in dic)
  {
        if (pair.Key == any_integer_value_to_compare)
        {
             Console.WriteLine(pair.Value);
        }
  }
  </code></pre>
  
  <p>How can I do that??</p>