How do I fully qualify type identifiers in generic methods in Delphi?
문제
This question came up when trying to assign the OnUDPRead event on an Indy IdUDPServer component. (DelphiXE Update 1)
The following auto-generated code gives a syntax error "Expected '>' but '.' found":
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
AData: TArray<System.Byte>; ABinding: TIdSocketHandle);
I can work around this by changing the declaration to:
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
AData: TArray<Byte>; ABinding: TIdSocketHandle);
For future reference, how do I fully qualify a type identifier in a generic method?
해결책
Fully qualified type identifiers are not (yet) supported. But you can circumvent this using a type alias:
type
TMyByte = System.Byte;
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
AData: TArray<TMyByte>; ABinding: TIdSocketHandle);
제휴하지 않습니다 StackOverflow