开发者

How do I fully qualify type identifiers in generic methods in Delphi?

This question came up when tryi开发者_运维问答ng 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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜