我想声明一个基本上包含类型的列表:
List<Type> types = new List<Type>() {Button, TextBox };
这可能吗?
最佳答案
试试这个:
List<Type> types = new List<Type>() { typeof(Button), typeof(TextBox) };
typeof()
运算符用于返回类型的 System.Type
。
对于对象实例,您可以调用继承自 Object 的 GetType()
方法。
关于c# - 声明类型列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1615723/