Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I annotate class of some object as type?

I want to create a

TDictionary<string, class of TControl>

that - as you can see - holds pairs of strings and references to TControl class definition to be able to call Create method on the dictionary elements at runtime.

Can I?

like image 967
Sándor Rakonczai Avatar asked Apr 14 '14 10:04

Sándor Rakonczai


1 Answers

The syntax you need is as follows:

type
  TControlClass = class of TControl;

And then you can declare the dictionary:

var
  Dict: TDictionary<string, TControlClass>;
like image 71
David Heffernan Avatar answered Nov 15 '22 00:11

David Heffernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!