title: Can There Be Private Extension Methods?
body: <p>Let's say I have a need for a simple private helper method, and intuitively in the code it would make sense as an extension method. Is there any way to encapsulate that helper to the only class that actually needs to use it?</p>
  
  <p>For example, I try this:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var value = 0;
          value = value.GetNext(); // Compiler error
      }
  
      static int GetNext(this int i)
      {
          return i + 1;
      }
  }
  </code></pre>
  
  <p>The compiler doesn't "see" the <code>GetNext()</code> extension method.  The error is:</p>
  
  <blockquote>
    <p>Extension method must be defined in a non-generic static class</p>
  </blockquote>
  
  <p>Fair enough, so I wrap it in its own class, but still encapsulated within the object where it belongs:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var value = 0;
          value = value.GetNext(); // Compiler error
      }
  
      static class Extensions
      {
          static int GetNext(this int i)
          {
              return i + 1;
          }
      }
  }
  </code></pre>
  
  <p>Still no dice.  Now the error states:</p>
  
  <blockquote>
    <p>Extension method must be defined in a top-level static class; Extensions is a nested class.</p>
  </blockquote>
  
  <p>Is there a compelling reason for this requirement?  There are cases where a helper method really should be privately encapsulated, and there are cases where the code is a lot cleaner and more readable/supportable if a helper method is an extension method.  For cases where these two intersect, can both be satisfied or do we have to choose one over the other?</p>