title: Is it possible to create an interface this general?
body: <p>I'm going to be creating a lot of classes like</p>
  
  <pre><code>public static class M2SA
  {
      // Median of 2 sorted arrays
  
      public static int Method ( int[] A, int[] B )
      {
          int m = A.Length, n = B.Length;
          if((m | n) == 0) 
              throw new ArgumentException("A and B cannot both be empty");
          int i = 0, j = 0, k = (m + n)/2; 
          while((i + j) &lt; k)
          {
              if(i == m) ++j;
              else if(j == n || A[i] &lt;= B[j]) ++i;
              else ++j;
          }
          if(i == m) return B[j];
          else if(j == n) return A[i];
          else return Math.Min(A[i],B[j]);
      }
  
      public static int Alternative ( int[] A, int[] B )
      {
          if ((A.Length | B.Length) == 0)
              throw new ArgumentException("A and B cannot both be empty");
          int[] mergedAndSorted = A.Concat(B).OrderBy(x =&gt; x).ToArray();
          return mergedAndSorted[mergedAndSorted.Length / 2];
      }
  
      public static bool Test ()
      {
          return false;//Placeholder - haven't implemented yet
      }
  }
  </code></pre>
  
  <p>in that they will all implement</p>
  
  <ul>
  <li>a <code>public static</code> method named <code>Method</code></li>
  <li>a <code>public static</code> method named <code>Alternative</code> which has the same signature as <code>Method</code></li>
  <li>a method <code>public static bool Test</code> that tests that whether <code>Method</code> and <code>Alternative</code> produce equivalent output for a given set of generated input.</li>
  </ul>
  
  <p>The classes may have other methods that serve as helpers. </p>
  
  <p>Is there a way I can create an interface general enough that it requires the above, but doesn't know anything beyond that? Or would it require that its methods have certain signatures? </p>
  
  <p>For example, I might have another class like </p>
  
  <pre><code>public static class UnstablePartition
  {
  
      public static void intswap(ref int a, ref int b)
      {
          // I'm amazed that there isn't already a method for this in the .NET library (???)
          int temp = a;
          a = b;
          b = temp;
      }
  
      public delegate bool UnaryPredicate (int i);
  
      public static void Method ( int[] arr, UnaryPredicate pred )
      {
          for(int i = 0, j = arr.Length; i &lt; j; )
          {
              if (!pred(arr[i])) ++i;
              else if (pred(arr[j])) --j;
              else intswap(ref arr[i],ref arr[j]);
          }
      }
  
      public static void Alternative(int[] arr, UnaryPredicate pred)
      {
          int[] partioned = new int[arr.Length];
          for (int ai = 0, pi = 0, pj = partioned.Length; ai &lt; arr.Length; ++ai)
          {
              if (pred(arr[ai])) partioned[pj--] = arr[ai];
              else partioned[pi++] = arr[ai];
          }
          Array.Copy(partioned, arr, partioned.Length);
      }
  
  
      public static bool Test()
      {
          return false;//Placeholder - haven't implemented yet
      }
  
  }
  </code></pre>
  
  <p>So I want an interface that is something like (I know the below is <em>completely</em> invalid ...)</p>
  
  <pre><code>public static interface InterviewQuestion
  {
      public static Method;
      public static Alternative;
      public static bool Test();
  }
  </code></pre>
  
  <p>and then I'll implement it like</p>
  
  <pre><code>public static class M2SA : InterviewQuestion
  </code></pre>