Casting a ListBox.SelectedObjectCollection to a ListBox.ObjectCollection?
问题 Is it possible to cast a ListBox.SelectedObjectCollection to a ListBox.ObjectCollection in C#? If so, how would I go about it? 回答1: I have a function that accepts List<string> . I can pass both SelectedItems and Items by casting them. Try this: SelectedItems.Cast<string>().ToList() Items.Cast<string>().ToList() <string> could be replaced with some other object type. 回答2: This is not possible. Instead, you should use an IList . Both of these types implement IList , so you can pass either one