Marking A Class Static in VB.NET

前端 未结 5 1713
你的背包
你的背包 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:51

    Module == static class

    If you just want a class that you can't inherit, use a NotInheritable class; but it won't be static/Shared. You could mark all the methods, properties, and members as Shared, but that's not strictly the same thing as a static class in C# since it's not enforced by the compiler.

    If you really want the VB.Net equivalent to a C# static class, use a Module. It can't be inherited and all members, properties, and methods are static/shared.

提交回复
热议问题