title: Implicitly convert collection (HashSet) to IEnumerable<T>
body: <p>I have a simple abstract enumeration class:</p>
  
  <pre><code>public abstract class Enumeration&lt;T&gt; {
  
      protected readonly T _value;
      private static readonly HashSet&lt;Enumeration&lt;T&gt;&gt; _values
          = new HastSet&lt;Enumeration&lt;T&gt;&gt;();
  
      protected Enumeration(T value) {
          _value = value;
          _values.Add(this);
      }
  
  }
  </code></pre>
  
  <p>Now I would like to have a method that returns every element in the HashSet, but not the HashSet itself ( -> as an IEnumerable).</p>
  
  <p>But this doesn't work:</p>
  
  <pre><code>public static IEnumerable&lt;T&gt; GetValues() {
       return _values;
  }
  </code></pre>
  
  <p>because I cannot implicitly convert <code>HashSet</code> to <code>IEnumerable&lt;T&gt;</code>, of course. The only way I can think of is looping through the HashSet and yielding every element, but I wonder if there's a way to do this automatically, like when you implicitly cast a list to an <code>IEnumerable&lt;T&gt;</code>.</p>