Home  |  Delphi .net Home  |  System.Buffer  |  GetByte Method
  
GetByte  
Method  
Gets the byte at the given index position in an array of primitive data
Buffer Class
System NameSpace
CF1.  Function GetByte ( Buffer : Array of PrimitiveTypes; Index : Integer ) : Byte; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The Buffer class treats primitive data arrays as blocks of bytes. An array of Int32 types would be treated as an block of bytes of size 4 times that of the Int32 array (Int32 takes up 4 bytes).
 
The byte value at Index in the Buffer is returned.
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Buffer
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  buffer  : Array of Int64;
  intVal  : Int64;
  byteVal : Byte;
  buffLen : Integer;
  i       : Integer;

begin
  // Set the array to be 5 elements of Int64's : 5 * 8 bytes = 40 total
  setLength(buffer, 5);

  // Fill the array with some numbers
  for i := 0 to Length(buffer)-1 do
    buffer[i] := i * 256;

  // Display the 4th array index value
  intVal := buffer[4];
  Console.WriteLine('buffer[4] = {0}', intVal.ToString);

  // Get the bytes of the 4th array index value
  for i := (4 * SizeOf(Int64)) to ((5 * SizeOf(Int64) -1)) do
  begin
    byteVal := System.Buffer.GetByte(buffer, i);
    Console.WriteLine('buffer byte {0} = {1}',
                      i.ToString, byteVal.ToString);
  end;

  Console.ReadLine;
end.
   buffer[4] = 1024
   buffer byte 32 = 0
   buffer byte 33 = 4
   buffer byte 34 = 0
   buffer byte 35 = 0
   buffer byte 36 = 0
   buffer byte 37 = 0
   buffer byte 38 = 0
   buffer byte 39 = 0
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author