Appccelerate.IO.Streams.StreamExtensionMethods.CompareStreamContentsTo C# (CSharp) Method

CompareStreamContentsTo() public static method

Compares the contents of the streams given.
public static CompareStreamContentsTo ( this actual, Stream expected ) : bool
actual this /// The actual. ///
expected Stream /// The expected. ///
return bool
        public static bool CompareStreamContentsTo(this Stream actual, Stream expected)
        {
            Ensure.ArgumentNotNull(actual, "actual");
            Ensure.ArgumentNotNull(expected, "expected");

            if (!expected.CanRead)
            {
                throw new ArgumentException("Expected stream is not readable");
            }

            if (!actual.CanRead)
            {
                throw new ArgumentException("Actual stream is not readable");
            }

            int i = 0;
            int j = 0;
            while (i == j && i != -1)
            {
                i = expected.ReadByte();
                j = actual.ReadByte();
            }

            return i == j;
        }
    }
StreamExtensionMethods