ExtensionMethod.NET Home of 820 C#, Visual Basic, F# and Javascript extension methods

FromDelimitedString

Returns a string list from a delimited string where you provide the delimiter.

Source

''' <summary>
''' Populates a list with the contents of a delimited string.
''' </summary>
''' <param name="ls"></param>
''' <param name="buf"></param>
''' <param name="delimiter"></param>
''' <returns></returns>
''' <remarks></remarks>
<Extension()> _
Public Function FromDelimitedString(ByVal ls As List(Of String), ByVal buf As String, ByVal delimiter As String) As List(Of String)            
    Dim items() As String = Split(buf, delimiter)
    Return items.ToList
End Function

Example

Dim buf As String = "Bill|Jim|John|James|Jacob"
Dim ls As New List(Of String)
ls = ls.FromDelimitedString(buf, "|")

Author: Blake Pell

Submitted on: 25 mrt 2010

Language: VB

Type: System.String<T>

Views: 2414