我想在其他地方协方差泛型集合
var d = myGrid.ItemSource as IEnumerable<Object>;
var e = d as ICollection<dynamic>;
e.Add(new anotherclass());
我需要在程序的不同地区访问的ItemSource做到这一点
List<anotherclass> ls = new List<anotherclass> {new anotherclass{Name = "me"}};
myGrid.ItemSource = ls;
。我需要将项目添加到列表中,而无需编译时间类型信息。投向IEnumerable的作品,但因为我需要添加项目集合我需要比这更多,因此试图将其转换为集合。
怎么可能?
+1,这很有效,谢谢。 – Jimmy