title: C# List<Stream> dispose/close
body: <p>I am setting up a subscription service to send reports to various people in our company on a schedule. I plan to email the reports, the reporting system I am using is able to export as PDF stream (rather than writing temp files). Most people will receive more than one report so I am trying to attach them all to one email doing something like</p>
  
  <pre><code>List&lt;Stream&gt; reports = new List&lt;Stream&gt;();
  //looping code for each users set of reports
  Stream stream = ReportSource.ReportDocument.ExportToStream(PortableDocFormat)
  reports.Add(stream);
  stream.Flush();  //unsure
  stream.Close();  //unsure
  //end looping code
  
  SmtpClient smtpClient = new SmtpClient(host, port);
  MailMessage message = new MailMessage(from, to, subject, body);
  
  foreach (Stream report in reports)
  {
      message.Attachments.Add(new Attachment(report, "application/pdf"));
  }                
  smtpClient.Send(message);
  </code></pre>
  
  <p>What I am unsure about is should I be flushing and closing the stream just after adding it to the list will this be ok? Or do I need to loop the List afterwards to flush and dispose? I am trying to avoid any memory leak that is possible.</p>