I have a generic List(Of Customer). The customer class has a name, address, and phone number properties. I also have a property of another class that accepts a customer name array. I am able to do this by doing the following:
Dim names As String()
Dim i As Integer = 0
'customer.GetCustomers is a List(of Customer)
For Each customer As Customer In customer.GetCustomers()
ReDim Preserve names(i)
names(i) = customer.Name
i += 1
Next
Then to set it:
'CustomerNames is a String()
Class.CustomerNames = names
Is there a better way to convert this to a string array? Any help is appreciated. Thanks.