 <p>Add new <code>static</code> class and define your extension methods inside it. Check out <a href="https://msdn.microsoft.com/en-IN/library/bb383977.aspx">MSDN documentation</a> for Extension methods.</p> <pre><code> namespace TrendsTwitterati { public partial class Default: System.Web.UI.Page { } public static class MyExtensions { 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>