「VB.NET」参照型としての文字列型のサンプル

2021年11月29日

書式
Dim 変数1 As String =値1
Dim 変数2 As String =変数1

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Module Module1
Public Sub Main()
Dim strA As String = "study"
Dim strB As String = strA
Console.WriteLine("インスタンスを参照する")
Console.WriteLine("{0} {1}", strA, strB)
strB = "skill"
Console.WriteLine("新しい文字列型のインスタンス生成")
Console.WriteLine("{0} {1}", strA, strB)
Console.ReadKey()
End Sub
End Module
Module Module1 Public Sub Main() Dim strA As String = "study" Dim strB As String = strA Console.WriteLine("インスタンスを参照する") Console.WriteLine("{0} {1}", strA, strB) strB = "skill" Console.WriteLine("新しい文字列型のインスタンス生成") Console.WriteLine("{0} {1}", strA, strB) Console.ReadKey() End Sub End Module
Module Module1

    Public Sub Main()

        Dim strA As String = "study"
        Dim strB As String = strA

        Console.WriteLine("インスタンスを参照する")
        Console.WriteLine("{0} {1}", strA, strB)

        strB = "skill"
        Console.WriteLine("新しい文字列型のインスタンス生成")
        Console.WriteLine("{0} {1}", strA, strB)

        Console.ReadKey()
    End Sub

End Module

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
インスタンスを参照する
study study
新しい文字列型のインスタンス生成
study skill
インスタンスを参照する study study 新しい文字列型のインスタンス生成 study skill
インスタンスを参照する
study study
新しい文字列型のインスタンス生成
study skill

 

VB.net

Posted by arkgame