简体   繁体   中英

What would be considered a VB.NET module in C#?

VB.NET has classes and Modules, so my first question is what is the difference? Also, I noticed that C# does not have modules, but just classes, is there something in place of modules or were they removed for C#?

About the closest thing to a VB module would be a static class in C#.

For Example:

In VB.NET

Module SomeModule
    Public Sub DoSomething
        MsgBox("Doing something!")
    End Sub
End Module

Same thing in C#:

public static class DoSomethingFuncs
{
    public static void DoSomething() {
        MessageBox.Show("Doing something!");
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM