MemoryStream.ReadByte 메서드

정의

현재 스트림에서 바이트를 읽습니다.

public:
 override int ReadByte();
public override int ReadByte ();
override this.ReadByte : unit -> int
Public Overrides Function ReadByte () As Integer

반환

Int32로 캐스팅된 바이트이거나 스트림의 끝에 도달한 경우 -1입니다.

예외

현재 스트림 인스턴스가 닫혀 있는 경우

예제

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 MemoryStream 클래스입니다.

// Read the remaining bytes, byte by byte.
while ( count < memStream->Length )
{
   byteArray[ count++ ] = Convert::ToByte( memStream->ReadByte() );
}
// Read the remaining bytes, byte by byte.
while(count < memStream.Length)
{
    byteArray[count++] = (byte)memStream.ReadByte();
}
' Read the remaining Bytes, Byte by Byte.
While(count < memStream.Length)
    byteArray(count) = _
        Convert.ToByte(memStream.ReadByte())
    count += 1
End While

설명

이 메서드는 ReadByte를 재정의합니다.

읽기 작업이 성공하면 스트림 내의 현재 위치가 1 바이트씩 고급화됩니다. 예외가 발생하면 스트림 내의 현재 위치는 변경되지 않습니다.

적용 대상

추가 정보