title: Is there a memcmp equivalent for comparing byte arrays in Mono?
body: <p>There is a well-known efficiency for comparing two byte-arrays in .Net by importing the <code>memcmp</code> function from <code>msvcrt.dll</code>, as described <a href="https://stackoverflow.com/a/1445405">here</a>.</p>
  
  <p>Is there an equivalent library import in mono?  Would it need to be different when running mono on linux or on windows?  Or is there another fast byte array comparison technique that works well in mono?  I'm looking for something better than just iterating over the arrays in c#.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Based on Matt Patenaude's comment, I think this might work well:</p>
  
  <pre><code>#if __MonoCS__
      [DllImport("c", CallingConvention = CallingConvention.Cdecl)]
  #else
      [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
  #endif
      public static extern int memcmp(byte[] b1, byte[] b2, UIntPtr count);
  </code></pre>
  
  <p>But I have not yet tried it.  I've never done p/invoke on mono before.  I'm using the signature recommended on <a href="http://www.pinvoke.net/default.aspx/msvcrt.memcmp" rel="nofollow noreferrer">pinvoke.net</a>.  Is this going to be compatible?</p>
  
  <p>Looking for a Mono-focused answer.  Thanks.</p>