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? Since the framework is compatible between C# and VB it would make sense that there would be a way to mark a class static, but there doesn't seem to be a way.
C# – Marking A Class Static in VB.NET
cvb.net
Related Topic
- C# – Case insensitive ‘Contains(string)’
- C# – When should I use a struct rather than a class in C#
- C# – ‘Static readonly’ vs. ‘const’
- Vb.net – Classes vs. Modules in VB.NET
- C# – How to return an empty IEnumerable
- Scala: list.flatten: no implicit argument matching parameter type (Any) = > Iterable[Any] was found
Best Answer
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 asShared
, 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.