Aggregate String Array
Public Function AggregateStrings(strings As IEnumerable(Of String), separator As String) As String
Return strings.Aggregate("", Function(txt As String, current As String)
If Not String.IsNullOrEmpty(txt) Then
Return String.Format("{0}{1}{2}", txt, separator , current)
End If
Return String.Format("{0}", current)
End Function)
End Function
Usage:
Dim values As List(Of String) = New List(Of String) From {"100", "200", "300"}
Dim result As String = AggregateStrings(values, " "c)
Return strings.Aggregate("", Function(txt As String, current As String)
If Not String.IsNullOrEmpty(txt) Then
Return String.Format("{0}{1}{2}", txt, separator , current)
End If
Return String.Format("{0}", current)
End Function)
End Function
Usage:
Dim values As List(Of String) = New List(Of String) From {"100", "200", "300"}
Dim result As String = AggregateStrings(values, " "c)
Comments
Post a Comment