C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Result: The String constructor returns a new string. We assign a reference variable to it.
Internally: The character array was assembled into a complete string, which can be used throughout your program.
VB.NET program that converts Char array to String
Module Module1
Sub Main()
' Create a Char array using assignment syntax.
Dim arr(8) As Char
arr(0) = "T"
arr(1) = "h"
arr(2) = "a"
arr(3) = "n"
arr(4) = "k"
arr(5) = " "
arr(6) = "y"
arr(7) = "o"
arr(8) = "u"
' Create a String from the Char array.
Dim value As String = New String(arr)
' Test.
Console.WriteLine(value = "Thank you")
End Sub
End Module
Output
True
With fewer allocations: Performance improves. Allocating objects like strings is usually slower than reusing a single array.