Home  |  Delphi .net Home  |  System.IO.MemoryStream  |  WriteByte Method
WriteByte  
Method  
Writes a Byte to the current position in the Memory Stream
MemoryStream Class
System.IO NameSpace
CF1.  Procedure WriteByte ( Value : Byte; ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
The Value byte is written to the current position in the Memory Stream.
 
The posuition is updated accordingly.
Microsoft MSDN Links
System.IO
System.IO.MemoryStream
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  Memory        : System.IO.MemoryStream;
  ByteAsInteger : Integer;

begin
  // Create our Memory Stream Writer
  Memory := System.IO.MemoryStream.Create;

  // Write to the stream
  Memory.WriteByte(1);
  Memory.WriteByte(2);
  Memory.WriteByte(3);

  // Position at the start of the stream
  Memory.Seek(0, SeekOrigin.Begin);

  // Now display the stream contents
  ByteAsInteger := Memory.ReadByte;

  while ByteAsInteger >= 0 do
  begin
    Console.WriteLine(ByteAsInteger.ToString);
    ByteAsInteger := Memory.ReadByte;
  end;

  // Close the stream
  Memory.Close;

  Console.Readline;
end.
Show full unit code
  1
  2
  3
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author