×

VB.Net Programs

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

By Nidhi Last Updated : November 11, 2024

String.Concat() Method in VB.Net

The Concat() method is used to concatenate two strings and return the concatenated string to the calling function.

Syntax

Function Concat (ByVal str1 as String, ByVal str2 as String) as String

Parameter(s)

  • Str1: String to be concatenated.
  • Str2: String to be concatenated.

Return Value

It returns the concatenated string based on specified strings.

VB.Net code to demonstrate the example of String.Concat() method

The source code to demonstrate the Concat() method of the String class is given below. The given program is compiled and executed successfully.

'VB.NET program to demonstrate the Concat() 
'method of String class.

Imports System

Module Module1
    Sub Main()
        Dim str1 As String = "Hello "
        Dim str2 As String = "World "
        Dim str3 As String

        str3 = String.Concat(str1, str2)

        Console.WriteLine("Str1: {0}", str1)
        Console.WriteLine("Str2: {0}", str2)
        Console.WriteLine("Str3: {0}", str3)
    End Sub
End Module

Output

Str1: Hello
Str2: World
Str3: Hello World
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 three strings str1, str2, and str3. Here, we concatenated two strings str1 and str2 and assigned the concatenated string into str3. After that, we printed all strings on the console screen.

VB.Net String Programs »


Comments and Discussions!

Load comments ↻





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