title: How to Dispose a list of objects;Does it Free the Memory
body: <p>I have the following class.</p>
  
  <pre><code>public class Foo
  {
      private string _DirName;
      private FileStream  _MyfileStream;
      public FileStream  MyfileStream
      {
          get { return _MyfileStream; }               
      }
  
      public string DirName
      {
          get { return _DirName; }
          set 
          { 
              _DirName = value;
              _MyfileStream = new FileStream(value, FileMode.Create); 
          }
      }            
  }
  </code></pre>
  
  <p>I have Created a List Of Foo as like the following:</p>
  
  <pre><code>List&lt;Foo&gt; FooList = new List&lt;Foo&gt;();
  FooList.Add(new Foo() { DirName = @"F:\sample\sample.txt" });
  FooList.Add(new Foo() { DirName = @"D:\sample\file.pdf" });
  </code></pre>
  
  <p>So each list item is creating a File stream. hence the number of streams increased as the number of list item increases. how can i dispose the allocated memory for these streams?</p>