Marking A Class Static in VB.NET

前端 未结 5 1708
你的背包
你的背包 2020-12-01 10:12

As just stated in a recent question and answer, you can\'t inherit from a static class. How does one enforce the rules that go along with static classes inside VB.NET? Sin

5条回答
  •  伪装坚强ぢ
    2020-12-01 10:43

    You can create static class in vb.net. The solution is

    Friend NotInheritable Class DB
        Public Shared AGE As Integer = 20
    End Class
    

    AGE variable is public static, you can use it in other code just like this

     Dim myage As Integer = DB.AGE
    

    Friend = public, NotInheritable = static

提交回复
热议问题