title: Best Practice - Removing item from generic collection in C#
body: <p>I'm using C# in Visual Studio 2008 with .NET 3.5.</p>
  
  <p>I have a generic dictionary that maps types of events to a generic list of subscribers.  A subscriber can be subscribed to more than one event.</p>
  
  <pre><code>private static Dictionary&lt;EventType, List&lt;ISubscriber&gt;&gt; _subscriptions;
  </code></pre>
  
  <p>To remove a subscriber from the subscription list, I can use either of these two options.</p>
  
  <p>Option 1:</p>
  
  <pre><code>ISubscriber subscriber;  // defined elsewhere
  foreach (EventType event in _subscriptions.Keys) {
      if (_subscriptions[event].Contains(subscriber)) {
          _subscriptions[event].Remove(subscriber);
      }
  }
  </code></pre>
  
  <p>Option 2:</p>
  
  <pre><code>ISubscriber subscriber;  // defined elsewhere
  foreach (EventType event in _subscriptions.Keys) {
      _subscriptions[event].Remove(subscriber);
  }
  </code></pre>
  
  <p>I have two questions.</p>
  
  <p>First, notice that Option 1 checks for existence before removing the item, while Option 2 uses a brute force removal since Remove() does not throw an exception.  Of these two, which is the preferred, "best-practice" way to do this?</p>
  
  <p>Second, is there another, "cleaner," more elegant way to do this, perhaps with a lambda expression or using a LINQ extension?  I'm still getting acclimated to these two features.</p>
  
  <p>Thanks.</p>
  
  <h2>EDIT</h2>
  
  <p>Just to clarify, I realize that the choice between Options 1 and 2 is a choice of speed (Option 2) versus maintainability (Option 1).  In this particular case, I'm not necessarily trying to optimize the code, although that is certainly a worthy consideration.  What I'm trying to understand is if there is a generally well-established practice for doing this.  If not, which option would you use in your own code?</p>