CSharp examples for System:Byte Array
Compare two byte arrays
using System.Text; using System;/*from www .j a v a 2s . co m*/ public class Main{ static bool Compare(this byte[] array1, bool startsWith, int[] anyMaskIndexes, params byte[] array2) { int len2 = array2.Length; if ((!startsWith && len2 != array1.Length) || len2 > array1.Length) { return false; } if (len2 == 0) { return true; } for (int i = 0; i < len2; i++) { if (anyMaskIndexes != null) { bool any = false; foreach (var j in anyMaskIndexes) { if (j == i) { any = true; break; } } if (any) { continue; } } if (array1[i] != array2[i]) { return false; } } return true; } static bool Compare(this byte[] array1, bool startsWith, params byte[] array2) { return Compare(array1, startsWith, null, array2); } public static bool Compare(this byte[] array1, int[] anyMaskIndexes, params byte[] array2) { return array1.Compare(false, anyMaskIndexes, array2); } public static bool Compare(this byte[] array1, params byte[] array2) { return array1.Compare(false, array2); } }