How to use Join Method in VB.NET

Join method combined two or more strings or objects (elements of array) together .
  • 2427

You can combined two or more strings or objects together. It is also combine elements of array. Join Method take first separator that  divide strings. I have used two different separator. In first line, I used ":" to represent separation between two strings  and in last line "vblf" for new line. You can use any separator to represent combination of lines.

Next, join method take name of strings that you want to combine to other string.

In the below join method str1 and str2 is joined using "," separator.
joinStr = String.Join(":", str1, str2)
 And the below statement join only one string with separator.

str3 As String = String.Join(vbLf, arr2)


    Sub Main()
         Dim str1 = "My name is"
        Dim str2 = "Sachin Tendulkar"
        Dim joinStr = String.Join(":", str1, str2)
         Dim arr2 As String() = New String()

, "Clark", "Hussey", "Lara"
         Dim str3 As String = String.Join(vbLf, arr2)
     End Sub



More Articles

© 2020 DotNetHeaven. All rights reserved.