VB.NET Concat and Insert Function
In this article we will learn how to use concat() and insert() function in VB.NET.
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
Figure 1.