Tutorial :Join Array Of Integers


What is the simplest/best practices way to get a comma separated list of the integers in the Integer array levels?

Dim levels(5) As Integer  Dim levelsStr As String    'put values in levels'    'Attempt 1: Failed'  levelsStr = String.Join(", ", levels) ' <- Error on levels'  'Value of type "1-dimensional array of Integer" cannot be converted'  'to "1-dimensional array of String" because "Integer" is not derived'  'from "String".'  


Try this

levelsStr = String.Join(", ", levels.Select(Function(x) x.ToString()).ToArray())  


Here's how you could do it with Array.ConvertAll:

Dim converter = New Converter(Of Integer, String)(Function(num) num.ToString)  Dim y = String.Join(", ", Array.ConvertAll(x, converter))  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »