How do I convert a List(Of T) to an ObservableCollection(Of T) in VB.NET?

前端 未结 6 2046
暗喜
暗喜 2020-12-31 01:33

Is there a way to do this without iterating through the List and adding the items to the ObservableCollection?

6条回答
  •  一向
    一向 (楼主)
    2020-12-31 02:08

    //Create an observable collection TObservable.
    
    ObservableCollection (TObservable) =new ObservableCollection (TObservable)();
    
    //Convert List items(OldListItems) to collection
    
    OldListItems.ForEach(x => TObservable.Add(x));
    

提交回复
热议问题