Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the Join() method of String class
Here, we are going to demonstrate the Join() method of String class in VB.Net.
Submitted by Nidhi, on January 19, 2021 [Last updated : March 07, 2023]
String.Join() Method in VB.Net
The Join() method is used to concatenate all elements of the string array, using the specified separator between each element.
Syntax
Function Join(ByVal separator as String, ByVal arr() as String) as String
Parameter(s)
- Separator: Specified separator
- Arr: Specified string array
Return Value
It returns the concatenated string.
VB.Net code to demonstrate the example of String.Join() method
The source code to demonstrate the Join() method of the String class is given below. The given program is compiled and executed successfully.
'VB.NET program to demonstrate the
'Join() method of String class.
Imports System
Module Module1
Sub Main()
Dim str() As String = {"Hello", "how", "are", "you"}
Dim result As String
result = String.Join("_", str)
Console.WriteLine("Result: #{0}#", result)
End Sub
End Module
Output
Result: #Hello_how_are_you#
Press any key to continue . . .
Explanation
In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program.
In the Main() function, we created a string array that contains some string elements. Here, we concatenated all string array elements and join each string element with a specified separator using Join() method of String class and print the concatenated string on the console screen.
VB.Net String Programs »