From msdn:
FileSystem.ReadByte
The byte, cast to an Int32, or -1 if the end of the stream has been reached.
So -1 is basically a “magic value”. Does this mean the bytes returned from streams are never negative? If not, why not?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C# the values of a
byteis a number between 0 and 255, so a byte is never negative.The
sbytedata type is a signed byte, so it has a value between -128 and 127.(In some other languages, for example Java, the
bytedata type is signed.)