Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I'm programming an application in VB.NET in which I need to take the Items from a ListBox, which are an ListBox.ObjectCollection and convert into a String array to be passed as a parameter to a Sub procedure. How should I do it?
Assuming .NET 3.5, and thus LINQ:
(From item As Object In yourListBox.ObjectCollection Select item.ToString()).ToArray()
This also assumes that the way you want to convert items to strings is via ToString() - but, of course, you can replace it with anything else
ToString()
Add a comment
Updating for .NET 4.6
(From item In yourListBox.Items Select value = item.ToString).ToArray()
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.