代码
BindingList<String> list = new BindingList<String>();
Console.WriteLine("Type: " + list.GetType());
产生输出
Type: System.ComponentModel.BindingList`1[System.String]
但我想要的只是“System.String”。
这个问题本质上与现有问题 Get type using reflection 相反.
最佳答案
您可以使用Type.GetGenericArguments
:
list.GetType().GetGenericArguments()[0];
关于c# - 在给定 Collection<T> 对象的情况下查找 "T",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21736568/