To my surprise, this code can be compiled without any errors/warnings. It caused a very strange issue due to a typo. (Corrupted the TEncoding.UTF8 instance in my case...)

To my surprise, this code can be compiled without any errors/warnings. It caused a very strange issue due to a typo. (Corrupted the TEncoding.UTF8 instance in my case...)

type
TMyMemoryStream = class(TMemoryStream)
  Value: Integer;
end;

procedure Test;
var
  encoding: TEncoding;
begin
  encoding := TEncoding.UTF8;
  TMyMemoryStream(encoding).Value := 3;
end;

// as operator will check that, though

Comments