简体   繁体   English

什么被认为是C#中的VB.NET模块?

[英]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? VB.NET有类和模块,所以我的第一个问题是有什么区别? 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#? 另外,我注意到C#没有模块,只是类,是否有代替模块的东西或是否为C#删除了?

About the closest thing to a VB module would be a static class in C#. 关于VB模块最接近的是C#中的静态类。

For Example: 例如:

In VB.NET 在VB.NET中

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

Same thing in C#: 在C#中也是如此:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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