Cast an IList to a Collection
Asked Answered
A

2

5

I need to cast an IList to a Collection (System.Collections.ObjectModel)

How do you go about this?

Appenzell answered 4/5, 2010 at 14:11 Comment(0)
C
9
Collection<MyClass> coll = new Collection<MyClass>(myIList);
Calculated answered 4/5, 2010 at 14:17 Comment(0)
Z
4

Just use the constructor:

IList<T> myList = ...
System.Collections.ObjectModel.Collection<T> omc = 
           new System.Collections.ObjectModel.Collection<T>(myList);
Zenda answered 4/5, 2010 at 14:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.