ADVERTISEMENT
ADVERTISEMENT

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

Here, we are going to demonstrate the Copy() method of the String class in VB.Net.
Submitted by Nidhi, on January 20, 2021

The Copy() method is used to create a new string with the value of the existing string.

Syntax:

Function Copy (ByVal str as String) as String

Parameters:

  • Str: String to be copied.

Return Value: It returns the string value to create a new instance of the string with the same value.

Program/Source Code:

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

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

Imports System

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

        str2 = String.Copy(str1)

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

Output:

Str1: Hello World
Str2: 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 two strings str1 and str2. Here, we copy the value of str1 to str2 using Copy() method and printed the values of both strings on the console screen.

VB.Net String Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.