Declaring a List of types

c#, list, types

Solution

Try this:

List<Type> types = new List<Type>() { typeof(Button), typeof(TextBox) };

The `typeof()` operator is used to return the `System.Type` of a type.

For object instances you can call the `GetType()` method inherited from Object.

Problem

I want to declare a list containing types basically: ``` List<Type> types = new List<Type>() {Button, TextBox }; ``` is this possible?

Original source