【问题标题】:Can I annotate class of some object as type?我可以将某个对象的类注释为类型吗?
【发布时间】:2014-04-14 10:03:18
【问题描述】:

我想创建一个

TDictionary<string, class of TControl>

如您所见,它包含字符串对和对 TControl 类定义的引用,以便能够在运行时调用字典元素上的 Create 方法。

我可以吗?

【问题讨论】:

    标签: delphi firemonkey


    【解决方案1】:

    你需要的语法如下:

    type
      TControlClass = class of TControl;
    

    然后你就可以声明字典了:

    var
      Dict: TDictionary<string, TControlClass>;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      • 2016-11-17
      • 1970-01-01
      • 1970-01-01
      • 2019-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多