get last element of array delphi

To get the last element of an array in Delphi, you can use the High function. Here's an example:

  myArray: array of Integer;
  lastElement: Integer;
  // Initialize the array with some values
  SetLength(myArray, 3);
  myArray[0] := 1;
  myArray[1] := 2;
  myArray[2] := 3;

  // Get the last element
  lastElement := myArray[High(myArray)];

  // Use the last element
  // ...

In this example, High(myArray) returns the highest index of the array, which corresponds to the last element. The value of the last element is then assigned to the lastElement variable.

Please note that the High function returns -1 if the array is empty. So, make sure to check the length of the array before using High to avoid accessing an invalid index.

I hope this helps!