title: Is this the proper way to iterate over Concurrentdictionary in C#
body: <p>I'm only using this code for an example. Assume I have the following Person class.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace dictionaryDisplay
  {
  class Person
  {
      public string FirstName { get; private set;}
      public string LastName { get; private set; }
  
      public Person(string firstName, string lastName)
      {
          this.FirstName = firstName;
          this.LastName = lastName;
  
      }
  
      public override string ToString()
      {
          return this.FirstName + " " + this.LastName;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Main Program</p>
  
  <pre><code>static void Main(string[] args)
      {
          ConcurrentDictionary&lt;int, Person&gt; personColl = new ConcurrentDictionary&lt;int,   Person&gt;();
  
          personColl.TryAdd(0, new Person("Dave","Howells"));
          personColl.TryAdd(1, new Person("Jastinder","Toor"));
  
          Person outPerson = null;
          personColl.TryRemove(0, out outPerson);
  
  
          //Is this safe to do?
          foreach (var display in personColl)
          {
              Console.WriteLine(display.Value);
          }
  
  
  
  
  
      }
  </code></pre>
  
  <ol>
  <li><p>is this the safe way of iterating over a concurrent dictionary? If not, what is the  safe way for doing it?</p></li>
  <li><p>Lets say that I want to remove a Person object from the dictionary. I use the tryRemove method, but what do I do with the outPerson object? the removed Person from the dictionary is stored in it. What do I do with the outPerson object to clear it completely? </p></li>
  </ol>