I want to convert the items to a String array or the type that I used to fill the ListBox.DataSource. The type has overridden ToString() but I can’t seems to get it converted, not even to String[].
String[] a = (String[])ListBox1.Items;
Contacts[] b = (Contacts[])ListBox1.Items;
Of course, if all you plan to do with
ais iterate over it, you don’t have to call ToArray(). You can directly use theIEnumerable<string>returned fromCast<string>(), e.g.:Or, if you have some way to convert strings to Contacts, you can do something like this: