How to get the underlying type of an Observable collection using reflection?
Cons开发者_JAVA百科ider following classes:
public class Order
{
public int OrderID { get; set; }
public string OrderDetails { get; set; }
}
public class Orders : ObservableCollection<Order>
{
}
Any Ideas?
You could use the GetGenericArguments method. Supposing you have an instance of Orders
:
var orders = new Orders();
var type = orders.GetType().BaseType.GetGenericArguments()[0];
精彩评论