title: How to define an iterator interface type?
body: <p>I've written a class that implements <code>IEnumerable&lt;T&gt;</code>. I have a method that returns <code>MyClass</code>. If I try to  <code>yield return</code> from within that method, the compiler tells me "... cannot be an iterator block because ... is not an iterator interface type".</p>
  
  <p>So, how can I define my own interface iterator type? Does it have to be "abstract" (can't have any methods defined)?</p>
  
  <p>What I want to do is write a bunch of chainable methods, so every method should return an instance of <code>MyClass</code>. But I need <code>MyClass</code> to be some kind of enumerable. Rather than using some underlying data type, I was hoping I could just <code>yield return</code> everywhere.</p>
  
  <hr>
  
  <p>@Oded:</p>
  
  <pre><code>class SharpQuery : IEnumerable&lt;HtmlNode&gt;
  {
      public SharpQuery Find(string selector)
      {
          foreach (var n in this)
          {
              // filter the results
              yield return node;
          }
      }
  }
  </code></pre>