public static bool Compare <T>(T[] source, T[] destination) { if (CollectionManager.ReferenceEquals(source, destination)) { return(true); } if (CollectionManager.ReferenceEquals(source, null)) { return(false); } if (CollectionManager.ReferenceEquals(destination, null)) { return(false); } return(Compare(source, 0, destination, 0, source.Length)); }
public static byte[] Trim(this byte[] array, byte[] leftTrimBytes, byte[] rightTrimBytes) { int end = array.Length - 1; int start = 0; if (leftTrimBytes != null) { while (start < array.Length) { if (leftTrimBytes.GetIndex(p => p == array[start]) < 0) { break; } start++; } } if (rightTrimBytes != null) { while (end >= start) { if (rightTrimBytes.GetIndex(p => p == array[end]) < 0) { break; } end--; } } int length = (end - start) + 1; if (length == array.Length) { return(array); } if (length == 0) { return(Bytes.Empty); } return(CollectionManager.GetSegment(array, start, length)); }