title: Making concrete return types generic
body: <p>Consider the following two methods, which are essentially copy and pasted versions of one another</p>
  
  <pre><code>public static List&lt;Book&gt; GetSubSet(List&lt;Book&gt; incomingList)
          {
              List&lt;Book&gt; returnList = new List&lt;Book&gt;();
              Random r = new Random();
              Console.WriteLine("Enter size of random subset: ");
              int randomInt = 0;
              int size = Convert.ToInt32(Console.ReadLine());
              while (size &gt; incomingList.Count)
              {
                  Console.WriteLine("Size too large, enter smaller subset: ");
                  size = Convert.ToInt32(Console.ReadLine());
              }
              while (returnList.Count &lt; size)
              {
                  randomInt = r.Next(incomingList.Count);
                  if (!returnList.Contains(incomingList[randomInt]))
                  {
                      returnList.Add(incomingList[randomInt]);
                  }
              }
              return returnList;
          }
  
   public static List&lt;Pet&gt; GetSubSet(List&lt;Pet&gt; incomingList)
          {
              Random r = new Random();
              List&lt;Pet&gt; returnList = new List&lt;Pet&gt;();
              Console.WriteLine("Enter random subset size: ");
              int size = Convert.ToInt32(Console.ReadLine());
              while (size &gt; incomingList.Count)
              {
                  Console.WriteLine("Size too large.  Enter random subset size: ");
                  size = Convert.ToInt32(Console.ReadLine());
              }
              while (returnList.Count &lt; size)
              {
                  int randomInt = r.Next(incomingList.Count);
                  if (!returnList.Contains(incomingList[randomInt]))
                  {
                      returnList.Add(incomingList[randomInt]);
                  }
              }
  
              return returnList;
          }
  </code></pre>
  
  <p>Obviously this isn't very OO and I would like to have a single method that could take care of whatever type.  I don't want to use inheritance because there's no logical connection or between books and dogs, and I don't want the types contained because containment doesn't make sense either.  So we're left with an interface.  Something like</p>
  
  <pre><code> interface ISubset
      {
  
          IEnumerable&lt;T&gt; GetSubset();
      }
  </code></pre>
  
  <p>I've seen but I don't know how to make the angle brackets accept any generic type.  How can I make the IEnumerable type generic so that I can implement the GetSubset method on any class?</p>