Centro is right that the module (or the NotInheritable class with members included) is the closest equivalent to the C # static class . So technically, nothing happens to her, because this is just one way to create this class of VB class. For example, you cannot say Public Shared Class Settings in VB, since you cannot put the Shared keyword in a class.
By itself, I would not call it bad practice if a particular circumstance requires a module, but otherwise the module (or other equivalents of a static class) is probably not the design choice you want for a loosely coupled test code. In addition, while the NotInheritable class with Shared members is more descriptive than just saying the module, there is at least one circumstance in which the module should be used instead.
When will you need to use modules in VB.Net? If you want to use extension methods , then this is your only option , because, as already mentioned, you cannot create a general (static) in VB.Net, you also cannot use extensions for NotInheritable classes. You should use the module as follows:
Imports System.Runtime.CompilerServices Public Module StringExtensions <Extension()> _ Public Function Remove( _ ByVal input As String, _ ByVal subStrings As String()) As String Return String.Join("", input.Split(subStrings, StringSplitOptions.None)).Trim() End Function End Module
In C #, you cannot use modules and must use static classes as follows:
public static class StringExtensions { public string Remove(this string input, string[] subStrings) { return string.Join("", input.Split(subStrings, StringSplitOptions.None)).Trim(); } }
source share