Declaring a List of types

后端 未结 5 1073
悲&欢浪女
悲&欢浪女 2020-12-10 23:53

I want to declare a list containing types basically:

List types = new List() {Button, TextBox };

is this possible?<

5条回答
  •  伪装坚强ぢ
    2020-12-11 00:37

    List types = new List{typeof(String), typeof(Int32) };
    

    You need to use the typeof keyword.

提交回复
热议问题