VB.NET Concat and Insert Function

In this article we will learn how to use concat() and insert() function in VB.NET.
  • 2874
 

In this article we will learn how to use concat() and insert() function in VB.NET.

Concat() Function

Concat() function is used to add two string and return a new string.

For example

Dim str1 As String

 Dim str2 As String

   str1 = "Rohatash "

     str2 = "Kumar"

      Console.WriteLine("concatenation of  str1 and str2 is = " & String.Concat(str1, str2))

 

Insert() Function

 

The Insert() function in String Class is used to insert a String in a specified index in the String.

 

For example

 

Dim str As String = "Hello Kumar"

 Dim insStr As String = "Rohatash "

  Dim strRes As String = str.Insert(6, insStr)

   Console.WriteLine("Insert is =" & strRes)

 

The below program defines both method.

Module Module1

    Sub Main()

        'Using Concate method

        Dim str1 As String

        Dim str2 As String

        str1 = "Rohatash "

        str2 = "Kumar"

        Console.WriteLine("concatenation of  str1 and str2 is = " & String.Concat(str1, str2))

        ' Using Insert method

        Dim str As String = "Hello Kumar"

        Dim insStr As String = "Rohatash "

        Dim strRes As String = str.Insert(6, insStr)

        Console.WriteLine("Insert is =" & strRes)

    End Sub

End Module
 

Output
 

o1.gif

Figure 1.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.