开发者

Underlying type in an empty Observable Collection

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜