建构函数重载 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


如有错误 欢迎指正