×

VB.Net Programs

VB.Net program to demonstrate the Join() method of String class

By Nidhi Last Updated : November 11, 2024

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 »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.