Reputation: 714
I want to save a list of object types into a variable.
For example something like this
Dim allowedTypes As New List(Of Type)
allowedTypes.Add(TextBox)
The above produces an error, however I need to save a list of object types in this list so that I could compare the allowedTypes when creating elements dynamically via a loop.
Is this possible in Vb.Net (Any alternative suggestions are welcome).
Upvotes: 0
Views: 533
Reputation: 876
You'll need to use the GetType
method, as in:
Dim allowedTypes as new List(Of Type)
allowedTypes.Add(GetType(TextBox))
Upvotes: 1