Search code examples
delphibinarywriter

How do I make the compiler choose the BinaryWriter.Write overload I want?


I am using binary readers and writers to read / write data to a file. For example for this:

MyWriter.Write(Ord(TMyEnum(2)));

I would expect it to write down SmallInt to be read with

MyReader.ReadSmallInt

But in IDE I see it writes down byte. How do I force the writer to write the type that I want?


Solution

  • Cast it to Smallint

    Smallint(SomeEnum)