建構函式多載 shared (VB.NET)

建構函式多載 shared (VB.NET)

Public Class BOOK
    Dim TITLE As String
    'Shared 資料成員 所有物件共享一份資料
    Public Shared discount As Single = 0.95

    Shared Sub MAIN()
        Dim B1 As New BOOK
        Dim B2 As New BOOK("VB入門")
        Console.WriteLine(B1.TITLE)
        Console.WriteLine(B2.TITLE)
        B1.discount = 0.95
        B2.discount = 0.19
        Console.WriteLine(B1.discount)
        Console.WriteLine(B2.discount)
        Console.WriteLine(BOOK.discount)
    End Sub

    Public Sub New()
        TITLE = "未定"
    End Sub
    Public Sub New(ByVal T As String)
        TITLE = T
    End Sub
End Class


如有錯誤 歡迎指正