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

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

Parameters:

  • Separator: Specified separator
  • Arr: Specified string array

Return Value: It returns the concatenated string.

Program/Source Code:

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 »



ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.