什么会被认为是在C#中VB.NET模块? [英] What would be considered a VB.NET module in C#?

查看:127
本文介绍了什么会被认为是在C#中VB.NET模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VB.NET有类和模块,所以我的第一个问题是有什么区别?另外,我注意到,C#不具备的模块,而只是类,是有什么替代模块的还是他们对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#?

推荐答案

关于最接近VB的模块将在C#中的静态类

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

例如:

在VB.NET

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

在C#中同样的事情:

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

这篇关于什么会被认为是在C#中VB.NET模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆