本文介绍了Csharp的“VB模块”版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 这是我的故事, 当我使用VB在Access中编写函数时,我在模块中创建了函数,只需调用函数名称即可轻松访问它们。使用VB的Windows应用程序中存在相同的选项 选项模块当我右键单击项目并选择添加时出现在VB中但不在C#中 现在我使用C#创建Windows应用程序。 我的问题是,... 如果我想在不同的模块中分离我的功能在VB中,我应该创建什么,新类,新组件? 谢谢 Perry Here is my story, When I wrote functions in Access using VB, I created functions in Modules where I could access them easily by just calling the name of the function. The same option exist in Windows Application using VB The option "Modules" appear when I right-click on the project and select "Add" in VB but not in C# Now I create Windows Application using C#. My question is, ...if I want to seperate my functions in different "modules" as in VB, what should I create, a new class, a new component? thanks Perry推荐答案 是的,这是一个C#没有区分模块和类之间的区别但是VB的区域。它们确实有细微差别 - 例如,您可以在模块中调用方法而无需指定模块名称,而您不能使用类,并提供(虚拟)相同的功能,您将方法声明为共享公开的。你这样做的方法是使用共享方法,以便你可以使用以下概念调用它们(但显然在C#中) VB Yeah, this is one of those areas where C# doesn''t distinguish the difference between modules and classes but VB does. They do have subtle differences - for instance you can invoke a method within a module without having to specify the module name, whereas you can''t with a class, and to provide (virtually) the same functionality you declare a method as shared instead of just public. The way you would do this is using shared methods so that you can invoke them using the following concept (but obviously in C#) VB 展开 | 选择 | Wrap | Line数字 这篇关于Csharp的“VB模块”版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-31 22:21