Reputation: 1061
I have a list of strings which could be anything from 1 to 25 strings long. I want to get the values off each index and add them a string so that I can send an email listing the values in the list.
Here is the list of strings:
Dim DataSyncFiles As List(Of String) = {"COPOR1P", "FFBIVDP", "FFCHLDP", "FFDBKDP", "FFDREQP", "FFINVHP", "FFJACCP", "FFJACPP", "FFJMNEP", "FFJOBSP", "FFPIVHP", "FFUNTTP", "FJBJB1P", "FJBJM1P", "FJBJM2P", "FJBJU1P", "FJBNT2P", "FPPBE9P", "FSANO1P", "FTPCP1P", "FTTEG1P", "FTTEO1P", "FTTRQ1P", "XATXTDP", "FFADDRP", "FFLOCNP"}.ToList()
So i want to loop through these and add them to one single string (string below). The list above is not always going to be 26 strings long.
Dim files as string
How am i best to do this?
Upvotes: 0
Views: 567
Reputation: 216243
It is a simple string.Join
fileList = string.Join("", DataSyncFiles)
The first parameter is the separator to use between the single elements of DataSyncFiles. If you don't need it just pass an empty string or Nothing
Upvotes: 2
Reputation: 1088
You can use String.Join(string, IEnumerable) to concat several strings to one big string
Upvotes: 1
Reputation: 4938
For i as integer = 0 to DataSyncFiles.Length - 1
files &= IIf(files <> "","," & filesDataSyncFiles(i),filesDataSyncFiles(i))
End For
Isnt a simple for loop required like this?
Upvotes: 0