开发者

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

开发者 https://www.devze.com 2023-01-25 17:08 出处:网络
This question came up when tryi开发者_运维问答ng to assign the OnUDPRead event on an Indy IdUDPServer component. (DelphiXE Update 1)

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

精彩评论

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