3

The code

BindingList<String> list = new BindingList<String>();
Console.WriteLine("Type: " + list.GetType());

produces the output

Type: System.ComponentModel.BindingList`1[System.String]

but what I want is just 'System.String'.

This question is essentially the opposite case from existing question Get type using reflection.

Community
  • 1
  • 1
NiloCK
  • 571
  • 1
  • 11
  • 33

1 Answers1

8

You can use Type.GetGenericArguments:

list.GetType().GetGenericArguments()[0];
D Stanley
  • 149,601
  • 11
  • 178
  • 240