c# Reflection - Find the Generic Type of a Collection
Posted
by Andy Clarke
on Stack Overflow
See other posts from Stack Overflow
or by Andy Clarke
Published on 2010-04-01T14:26:21Z
Indexed on
2010/04/01
14:33 UTC
Read the original article
Hit count: 258
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?
© Stack Overflow or respective owner