TryMemCmp() public static méthode

public static TryMemCmp ( byte s1, byte s2, UIntPtr size, int &result ) : bool
s1 byte
s2 byte
size System.UIntPtr
result int
Résultat bool
Exemple #1
0
        private static bool UnsafeFastEquals(byte[] x, byte[] y)
        {
            int num;

            Contract.Assert(x != null);
            Contract.Assert(y != null);
            Contract.Assert(0 < x.Length);
            Contract.Assert(x.Length == y.Length);
            if (!UnsafeNativeMethods.TryMemCmp(x, y, new UIntPtr((uint)x.Length), out num))
            {
                Interlocked.Exchange(ref _isFastEqualsDisabled, 1);
                return(SlowEquals(x, y));
            }
            return(num == 0);
        }
        private static bool UnsafeFastEquals(byte[] x, byte[] y)
        {
#if DEBUG
            Contract.Assert(x != null, "x != null");
            Contract.Assert(y != null, "y != null");
            Contract.Assert(0 < x.Length, "0 < x.Length");
            Contract.Assert(x.Length == y.Length, "x.Length == y.Length");
#endif // if DEBUG
            int result;
            if (!UnsafeNativeMethods.TryMemCmp(x, y, new UIntPtr(unchecked (( uint )x.Length)), out result))
            {
                Interlocked.Exchange(ref _isFastEqualsDisabled, 1);
                return(SlowEquals(x, y));
            }

            return(result == 0);
        }