Chr*_*ell 2 c# collections casting listboxitems
是否可以将ListBox.SelectedObjectCollection转换为C#中的ListBox.ObjectCollection?如果是这样,我该怎么办呢?
我有一个接受的功能List<string>.
我可以通过强制转换SelectedItems和Items来传递它们.
试试这个:
SelectedItems.Cast<string>().ToList()
Items.Cast<string>().ToList()
Run Code Online (Sandbox Code Playgroud)
<string> 可以用其他一些对象类型替换.