开发者

Underlying type in an empty Observable Collection

开发者 https://www.devze.com 2023-01-07 06:42 出处:网络
How to get the underlying type of an Observable collection using reflection? Cons开发者_JAVA百科ider following classes:

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消