VB.Net Tutorial/Data Type/String Copy

Материал из VB Эксперт
Перейти к: навигация, поиск

Use the overloaded operator (=) to copy string

Option Strict On
 Imports System
 Class Tester
    Public Shared Sub Main( )
       Dim s1 As String = "abcd"
       Dim s2 As String = "ABCD"
       
       Dim s6 As String = s1
       Console.WriteLine("s6 = s1: {0}", s6)
    End Sub "Main
 End Class "Tester
s6 = s1: abcd

Use the String Copy method

Option Strict On
 Imports System
 Class Tester
    Public Shared Sub Main( )
       Dim s1 As String = "abcd"
       Dim s2 As String = "ABCD"
       " the String copy method
       Dim s5 As String = String.Copy(s2)
       Console.WriteLine("s5 copied from s2: {0}", s5)
    End Sub "Main
 End Class "Tester
s5 copied from s2: ABCD