Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How Do You Cast A IEnumerable List To A Listbox Object Collection?

$
0
0
It's easy to cast a Listbox.ObjectCollection to a list to perform enumerations on but what about if you want to go the other way? I KNOW YOU CAN USE A FOREACH( Like

 foreach (string d in the_domains)
                {
                    this.dList.Add(d);
                }



Now

 var the_domains = domains.Items.Cast<string>().Where(item => (item.Contains("Is Available")));
                foreach (string d in the_domains)
                {
                    this.lstbx_domains.Items.Add(d);
                }




works find but what if I want to now convert the_domains? I've tried a simple case like
(Listbox.ObjectCollection)the_domains


This works but it gets generates a exception.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>