{"id":90,"date":"2011-05-22T08:01:22","date_gmt":"2011-05-22T08:01:22","guid":{"rendered":"http:\/\/devnot.wordpress.com\/?p=90"},"modified":"2011-05-22T08:01:22","modified_gmt":"2011-05-22T08:01:22","slug":"compare-two-bytes-buffers","status":"publish","type":"post","link":"https:\/\/thomas-jansen.eu\/?p=90","title":{"rendered":"Compare two bytes buffers"},"content":{"rendered":"<p>Comparing two arrays.<\/p>\n<p><b>What doesn&#8217;t work<\/b><\/p>\n<pre>\n   int[] a = new int[2]{1,2};\n   int[] b = new int[2]{1,2};\n\n   if (a.Equals(b))\n   {\n      \/\/ No match. The Array objects differ although they contain the same value.\n   }\n   \n   b = a;\n   \n   if (a.Equals(b))\n   {\n      \/\/ Match, the Array objects are the same.\n   }\n<\/pre>\n<p><b>What does work<\/b><\/p>\n<p>Strangely enough the Array function does not contain a compare function. <\/p>\n<p>To compare two buffers use the following code<\/p>\n<pre>i\nint i;\nfor (int i=0; i &lt; first.Length; i++)\n{\n   if (first[i] != second[i])\n   {\n      return false;\n   }\n}\n<\/pre>\n<p>Note this code is optimized by the compiler which detects 0 &lt; Length loops.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Comparing two arrays. What doesn&#8217;t work int[] a = new int[2]{1,2}; int[] b = new int[2]{1,2}; if (a.Equals(b)) { \/\/ No match. The Array objects differ although they contain the same value. } b = a; if (a.Equals(b)) { \/\/ Match, the Array objects are the same. } What does work Strangely enough the Array [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=90"}],"version-history":[{"count":0,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}