ICSharpCode.SharpZipLib.Tests.TestSupport.WindowedStream.Read C# (CSharp) Méthode

Read() public méthode

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
The sum of and is larger than the buffer length. /// is null. /// or is negative. An I/O error occurs. The stream does not support reading. Methods were called after the stream was closed.
public Read ( byte buffer, int offset, int count ) : int
buffer byte An array of bytes. When this method returns, the buffer contains the specified byte array with the values between and ( + - 1) replaced by the bytes read from the current source.
offset int The zero-based byte offset in at which to begin storing the data read from the current stream.
count int The maximum number of bytes to be read from the current stream.
Résultat int
        public override int Read(byte[] buffer, int offset, int count)
        {
            int bytesRead = 0;
            while (count > 0) {
                int value = ringBuffer_.ReadByte();
                if (value >= 0) {
                    buffer[offset] = (byte)(value & 0xff);
                    offset++;
                    bytesRead++;
                    count--;
                } else {
                    break;
                }
            }

            return bytesRead;
        }