TStreamHelper.ReadBuffer<T>(T) Method

Reads a value of a value type, which could be an Integer, record, etc., from the stream.

Namespace: Spring.Helpers
public
 procedure ReadBuffer<T: record>(var value: T); overload;

Type Parameters

T

Parameters

value
Type: T

Tip

The generic argument could be omitted if the compiler can automatically inreference the type.

The following example demonstrates how to use the generic ReadBuffer<T> and WriteBuffer<T>methods.

procedure TestStreamHelper;
var
  stream: TStream;
  value: Integer;
begin
  stream := TMemoryStream.Create;
  try
    value := 2;
    stream.WriteBuffer(value);
    stream.Position := 0;
    stream.ReadBuffer<Integer>(value);
  finally
    stream.Free;
  end;
end;