c# Reflection - Find the Generic Type of a Collection
- by Andy Clarke
Hi,
I'm reflecting a property 'Blah' its Type is ICollection
public ICollection<string> Blah { get; set; }
private void button1_Click(object sender, RoutedEventArgs e)
{
var pi = GetType().GetProperty("Blah");
MessageBox.Show(pi.PropertyType.ToString());
}
This gives me (as you'd expect!) ICollection<string> ...
But really I want to get the collection type i.e. ICollection (rather than ICollection<string>) - does anyone know how i'd do this please?