title: Code Contract C# ensure value is in array
body: <p>This is most likely very simple but I can't seem to figure it out:)</p>
  
  <p>I have 2 arrays of int.
  I want to make sure one value is in both arrays using code contracts in some form.
  If the value is not both arrays I don't want to continue</p>
  
  <p>Can this be done? 
  I was thinking of something like this but can't seem to get it to work</p>
  
  <pre><code>Contract.Requires(g[variable ] == y[variable]) 
  </code></pre>
  
  <p>The value must be in the same posion in both arrays</p>
  
  <p>This is what I have now</p>
  
  <pre><code> private static int FirstCut(int[] g, int[] h)
          {
              int x = 0;
  
              Contract.Requires(g.Length &gt; 0);            
              Contract.Requires(g.Length == h.Length); //skal være lige lange
  
              while (g[x] != h[x])
              {
                  x++;
              } 
              return x;
          }
  </code></pre>
  
  <p>Regards </p>
  
  <p>Birger</p>