title: How to write a generic extension method which wraps object in an enumerable?
body: <p>I'm trying to write an extension method which accepts an object of type <code>T</code> and returns <code>IEnumerable&lt;T&gt;</code>.</p>
  
  <p>Here's my first attempt:</p>
  
  <pre><code>internal static class ObjectExtensions&lt;T&gt;
  {
      public static IEnumerable&lt;T&gt; Yield(this T item)
      {
          yield return item;
      }
  }
  </code></pre>
  
  <p>This function works, but only if I write <code>ObjectExtensions&lt;Foo&gt;.Yield(foo)</code>: <code>foo.Yield()</code> doesn't resolve.</p>
  
  <p><em>Is there a way to declare an extension method which returns a generic based on the type of the input?</em></p>
  
  <p>(I've since discovered <code>Enumerable.Repeat</code> meets my original requirements, so this question is more curiosity.)</p>