C# BinaryWriter Write(SByte)

Description

BinaryWriter Write(SByte) Writes a signed byte to the current stream and advances the stream position by one byte.

Syntax

BinaryWriter.Write(SByte) has the following syntax.


[CLSCompliantAttribute(false)]
public virtual void Write(
  sbyte value
)

Parameters

BinaryWriter.Write(SByte) has the following parameters.

  • value - The signed byte to write.

Returns

BinaryWriter.Write(SByte) method returns

Example


using System;/*from   w  w w .  j a v  a2  s.  c o m*/
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)2);
        }

        using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
        {
            Console.WriteLine(reader.ReadSByte());
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter