title: Extension method must be defined in a non-generic static class
body: <p>I have this code in web forms:</p>
  
  <pre><code>namespace TrendsTwitterati
  {
      public partial class Default : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              List&lt;TweetEntity&gt; tweetEntity = tt.GetTweetEntity(1, "")
                  .DistinctBy(e =&gt; e.EntityPicURL);
          }
  
          public static IEnumerable&lt;TSource&gt; DistinctBy&lt;TSource, TKey&gt;(
              this IEnumerable&lt;TSource&gt; source, Func&lt;TSource, TKey&gt; keySelector)
          {
              HashSet&lt;TKey&gt; seenKeys = new HashSet&lt;TKey&gt;();
              foreach (TSource element in source)
              {
                  if (seenKeys.Add(keySelector(element)))
                  {
                      yield return element;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>When I compile this code I get the error</p>
  
  <blockquote>
    <p>Extension method must be defined in a non-generic static class.</p>
  </blockquote>
  
  <p>My question is</p>
  
  <ol>
  <li>I cannot change this partial class to static. How will I accomplish the same without it?</li>
  </ol>