如何在 Delphi 中的泛型方法中完全限定类型标识符?

发布于 2024-10-03 11:03:51 字数 491 浏览 1 评论 0原文

当尝试在 Indy IdUDPServer 组件上分配 OnUDPRead 事件时出现了这个问题。 (DelphiXE 更新 1)

以下自动生成的代码给出语法错误“Expected '>'但 '。'发现”:

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  AData: TArray<System.Byte>; ABinding: TIdSocketHandle);

我可以通过将声明更改为来解决此问题:

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  AData: TArray<Byte>; ABinding: TIdSocketHandle);

为了将来参考,如何在泛型方法中完全限定类型标识符?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自此以后,行同陌路 2024-10-10 11:03:51

(尚)不支持完全限定的类型标识符。但您可以使用类型别名来规避此问题:

type
  TMyByte = System.Byte;

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  AData: TArray<TMyByte>; ABinding: TIdSocketHandle);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文