ToDelimitedString
''' <summary> ''' Returns a delimited string from the list. ''' </summary> ''' <param name="ls"></param> ''' <param name="delimiter"></param> ''' <returns></returns> ''' <remarks> ''' </remarks> <Extension()> _ Public Function ToDelimitedString(ByVal ls As List(Of String), ByVal delimiter As String) As String Dim sb As New StringBuilder For Each buf As String In ls sb.Append(buf) sb.Append(delimiter) Next ' The final delimiter is trimmed off since there is no record after that item Return sb.ToString.Trim(delimiter) End FunctionExample:
Dim ls As New List(Of String) ls.Add("Blake") ls.Add("Bob") ls.Add("William") ls.Add("Jacob") Dim myString As String = ls.ToDelimitedString(",")
Description
Converts a List(Of String) into a delimited string.
Details
- Author: Blake Pell
- Submitted on: 25-3-2010 15:47:00
- Language: VB
- Type: System.String<T>
- Views: 2559
Double click on the code to select all.