Convert SelectedObjectCollection to Collection of Specific Type

Posted by Jonathan Wood on Stack Overflow See other posts from Stack Overflow or by Jonathan Wood
Published on 2013-06-28T06:53:22Z Indexed on 2013/06/28 16:21 UTC
Read the original article Hit count: 308

I have a WinForms multiselect listbox, and each item in the listbox is of type MyClass.

I am also writing a method that needs to take a parameter that is a collection of MyClass. It could be of type MyClass[], List<MyClass>, IList<MyClass>, IEnumerable<MyClass>, etc. Any of those would work fine.

Somehow, I need to pass the selected items in the listbox to my method. But how would I convert SelectedObjectCollection to any of the MyClass collection types described above?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms