Hello,
I have the following method in C#:
public T Read<T>()
{
T[] t = new T[1];
int s = Marshal.SizeOf(typeof(T));
if (index + s > size)
throw new Exception("Error 101 Celebrity");
GCHandle handle = GCHandle.Alloc(t, GCHandleType.Pinned);
Marshal.Copy(dataRead, index, handle.AddrOfPinnedObject(), s);
index += s;
return t[0];
}
dataRead is a byte[] array. index and size are integer type.
The function reads a type from dataRead(byte[]) and increases the index(index+=type).
All over the net,when I google "Delphi generics" - all it appears is Trecords and classes,which is not what I need.
How do I make that code in Delphi?