为什么要使用模块而不是类? [英] Why use a module instead of class?
问题描述
我见过几个关于模块有用性的例子。为什么要使用模块
而不是类?
如果我将一个方法放入Module1,它是如何从其他类调用的?
谢谢,
Brett
I''ve seen few examples on the usefulness of a module. Why use a module
instead of a class?
If I put a method into Module1, how is it called from other classes?
Thanks,
Brett
推荐答案
方法是制作共享程序集的简便方法。所有公共程序都是
本质上是共享的。该模块无法实例化。所以你打电话给
它只是作为module.method
-
--Eric Cathell,MCSA
"布雷特" < no@spam.com>在消息中写道
新闻:哦************** @ TK2MSFTNGP12.phx.gbl ...
Methods are easy ways of making shared assemblies. All public procedures are
intrinsically Shared. The module can not be instantiated. So you would call
it simply as module.method
--
--Eric Cathell, MCSA
"Brett" <no@spam.com> wrote in message
news:Oh**************@TK2MSFTNGP12.phx.gbl...
我见过关于模块有用性的几个例子。为什么使用模块而不是类?
如果我将一个方法放入Module1,它是如何从其他类调用的?
谢谢,> Brett
I''ve seen few examples on the usefulness of a module. Why use a module
instead of a class?
If I put a method into Module1, how is it called from other classes?
Thanks,
Brett
Brett写道:
Brett wrote:
我见过几个关于有用性的例子一个模块。为什么使用
模块而不是类?
因为您拥有的全球权利不属于任何
级别。类实例成员用于< things>对某个特定对象有所作为
的东西;类共享成员用于< things>
与一般的课程有关;模块成员用于
global< things> (其中< thing>是一个变量,一个函数,无论如何)。
OOP纯粹主义者将解密模块的使用,实际上是全局< things>,
但是他们有自己的位置。
如果我把一个方法放到Module1中,它是如何从其他类调用的?
I''ve seen few examples on the usefulness of a module. Why use a module instead of a class?
Because you have global entitites that don''t meaningfully belong to any
class. Class instance members are for <things> that have something to
do with a particular object; Class shared members are for <things> that
have something to do with a class in general; Module members are for
global <things> (where a <thing> is a variable, a function, whatever).
OOP purists will decry the use of Modules, and indeed global <things>,
but they have their place.
If I put a method into Module1, how is it called from other classes?
模块模块1
Public Sub MySub()
''...
End Sub
结束模块
然后从应用程序的任何地方:
MySub
-
Larry Lard
回复团体请
Module Module1
Public Sub MySub()
''...
End Sub
End Module
then from anywhere in the app:
MySub
--
Larry Lard
Replies to group please
" Brett" < no@spam.com> schrieb:
"Brett" <no@spam.com> schrieb:
我见过几个关于模块有用性的例子。为什么要使用模块而不是类?
如果我将一个方法放入Module1,它是如何从其他类调用的?
I''ve seen few examples on the usefulness of a module. Why use a module
instead of a class?
If I put a method into Module1, how is it called from other classes?
除了其他回复之外,您还可以在此处找到关于此
主题的讨论:
< URL:http:// groups。 google.com/groups?q=dotnet.languages+vb+modules+class>
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>
In addition to the other replies, you will find previous discussions on this
topic here:
<URL:http://groups.google.com/groups?q=dotnet.languages+vb+modules+class>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
这篇关于为什么要使用模块而不是类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!