C# BinaryReader ReadSByte
Description
BinaryReader ReadSByte
Reads a signed byte from this
stream and advances the current position of the stream by one byte.
Syntax
BinaryReader.ReadSByte
has the following syntax.
[CLSCompliantAttribute(false)]
public virtual sbyte ReadSByte()
Returns
BinaryReader.ReadSByte
method returns A signed byte read from the current stream.
Example
using System;//from w w w. j a va 2 s.c om
using System.IO;
class ConsoleApplication
{
const string fileName = "data.dat";
static void Main()
{
using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
{
writer.Write((SByte)10);
}
using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
{
Console.WriteLine(reader.ReadSByte());
}
}
}
The code above generates the following result.