【发布时间】:2011-02-03 09:37:45
【问题描述】:
我正在反映一个属性“Blah”,它的类型是 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());
}
这给了我(如你所料!)ICollection<string> ...
但我真的想获得集合类型,即ICollection(而不是ICollection<string>)——有人知道我会怎么做吗?
【问题讨论】:
-
但是它的类型是
ICollection<string>... -
同意,
ICollection和ICollection<T>是两种完全不同的类型。
标签: c# reflection properties types