MemoryStream: why convert to byte after readByte
In this example from MS , you'll notice that after we read a byte from memory stream, it goes into an int which must then be converted to byte. It stikes me as strange that a function like .ReadByte() doesn't return a byte in the first place. Is there a reason why MS did it this way? // Read the remaining bytes, byte by byte. while(count < memStream.Length) { byteArray[count++] = Convert.ToByte(memStream.ReadByte()); } a thought occured to me. Perhaps this comes down to usage. Perhaps ReadByte() is often used to retrieve short lengths, which subsequents get consumed in the retrieve via length