类和模块之间的区别 [英] Difference between Class and module

查看:114
本文介绍了类和模块之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vb.net


嘿,有人可以告诉我

类和模块之间的差异以及每个模块的使用时间比较到

其他?


任何帮助都会很棒


提前付款

vb.net

Hey there, could someone just tell me what the differnce is between
classes and modules and when each one would be used compared to the
other?

Any help would be great

Thanx in advance

推荐答案

Bonzol,


在这个新闻组中有一千次提出问题。


模块是一个只有共享成员的类的简单格式。


如果你已经在
您的VB6转换程序。


如果您想了解更多,请在Google新闻组中尝试搜索。

http://groups.google.com/group/micro...rch+th是+组


但是请随时再次提出这类问题。你不能知道这是经常被问到的b $ b。


我希望这能给出一个想法


Cor


" Bonzol" <博**** @ hotmail.com> schreef in bericht

news:11 ********************** @ p79g2000cwp.googlegr oups.com ...
Bonzol,

One of the thousand times asked question in this newsgroup.

A module is a simple format of a Class with only Shared members.

There is never a reason to use a module execpt if you have that already in
your VB6 converted program.

If you want to know more try a search on that in Google Newsgroups.

http://groups.google.com/group/micro...rch+this+group

However feel free to ask this kind of questions again. You could not have
knowed that it is so often asked.

I hope that this gives an idea

Cor

"Bonzol" <Bo****@hotmail.com> schreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...
vb.net

嘿,有人可以告诉我
类和模块之间的差异以及何时使用它们与
其他相比?

任何帮助都会很棒

Thanx提前
vb.net

Hey there, could someone just tell me what the differnce is between
classes and modules and when each one would be used compared to the
other?

Any help would be great

Thanx in advance



嗯,,,: - |
Hmmm ,,, :-|
如果您已经在VB6转换程序中使用了模块execpt,则永远不会有理由。


这只是你的意见Cor


回答你的问题Bonzol


什么是VB.Net中的模块?

VB.Net中的模块=一个类,其中每个成员都隐含地理解了每个成员的
。当使用

成员时,不需要提供模块名称。


模块编译为NotInheritable类,具有属性调用

StandardModuleAttribute附加。至于编译后的代码,有没有区别的




然而,这也是为什么全OOP阵营中的人们说你的原因

不应该使用模块

a NotInheritable(密封)类只包含Shared(静态)

方法不是很好的面向对象设计。 :-)


我认为有两种情况使用模块可能有效


1.你不关心OOP规则,只想尽可能快地写入

,尽可能简单的程序在你的

意见中有效使用模块(它' '风格的东西)我亲自把

类中的所有东西都当作一个对象来表示

(一个模块可以节省很多打字)


2.当你想要覆盖VB.net的标准方法调用行为时


就像一个更好的IIF


公共函数IIf(Of T)(ByVal表达式为布尔值,_

ByVal truePart为T,ByVal falsePart为T)为T


如果表达然后


返回truePart


否则


返回falsePart

结束如果


结束功能


这个在模块中会拨打iif i的电话你的代码被重定向到

这个更好的iif方法所以不需要改变你的所有代码你只需要编写

更好的方法作为语言功能(在以前的版本中),b / b
将来可以利用语言增强功能我们没有

有仿制药,所以在这种情况下这是一个很好的功能)


问候


Michel Posseth [MCP]



" Cor Ligthert [MVP]" <无************ @ planet.nl> schreef in bericht

新闻:OJ ************** @ TK2MSFTNGP02.phx.gbl ... Bonzol,

其中一个千万次在这个新闻组中提出问题。

一个模块是一个只有共享成员的类的简单格式。

如果你有一个模块execpt是没有理由的已经在你的VB6转换程序中已经有了。

如果你想了解更多,请在Google新闻组中尝试搜索。

http://groups.google.com/group/micro...rch+this+group

但是请随意再问一遍这个问题。你不可能知道它经常被问到。

我希望这能给出一个想法

Cor

" Bonzol" <博**** @ hotmail.com> schreef in bericht
新闻:11 ********************** @ p79g2000cwp.googlegr oups.com ...
There is never a reason to use a module execpt if you have that already in
your VB6 converted program.
That is just your opinion Cor

To answer your question Bonzol

What is a module in VB.Net ?

A Module in VB.Net = a Class where Shared is implicitly understood for
each member. And the module name doesn''t need to be supplied when the
members are used.

A Module compiles down to a NotInheritable class, with an attribute called
StandardModuleAttribute attached. As far as the compiled code goes, there''s
no difference.

However here is also the catch why people in the full OOP camp say you
shouldn`t use modules
a NotInheritable(sealed) class which only consists of Shared (static)
methods is not very good object-oriented design. :-)

In my opinion there are two situations in wich using a Module might be valid

1. You do not care about OOP rules and just want to write as fast as
possible and as easy as possible a program in a situation were it is in your
opinion valid to use a module ( it''s a style thingy ) i personally wrap
everything in a class when it can be represented as an object
( a module can save you a lot of typing )

2. when you want to override the standard method call behavior of VB.net

like a better IIF

Public Function IIf(Of T)(ByVal expression As Boolean, _
ByVal truePart As T, ByVal falsePart As T) As T

If expression Then

Return truePart

Else

Return falsePart

End If

End Function

This in a module will make anny call to iif in your code be redirected to
this "better" iif method so instead of having to change all your code you
can take advantage of language enhancements in the future by just writing
better methods as the language features ( in previous versions we did not
have generics , so in this situation it is a nice feature to have )

regards

Michel Posseth [MCP]



"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:OJ**************@TK2MSFTNGP02.phx.gbl... Bonzol,

One of the thousand times asked question in this newsgroup.

A module is a simple format of a Class with only Shared members.

There is never a reason to use a module execpt if you have that already in
your VB6 converted program.

If you want to know more try a search on that in Google Newsgroups.

http://groups.google.com/group/micro...rch+this+group

However feel free to ask this kind of questions again. You could not have
knowed that it is so often asked.

I hope that this gives an idea

Cor

"Bonzol" <Bo****@hotmail.com> schreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...
vb.net

嘿那里,有人可以告诉我
类和模块之间的差异,以及何时使用它们与
其他相比?

任何帮助都会很棒

Thanx提前
vb.net

Hey there, could someone just tell me what the differnce is between
classes and modules and when each one would be used compared to the
other?

Any help would be great

Thanx in advance




Michel,


你已经写完了为什么我有这个意见,我无法描述

更好。


:-)


Cor


" Michel Posseth [MCP]" < MS ** @ posseth.com> schreef in bericht

news:el ************** @ TK2MSFTNGP03.phx.gbl ...
Michel,

You have exactly written why I have that opinion, I could not have described
it better.

:-)

Cor

"Michel Posseth [MCP]" <MS**@posseth.com> schreef in bericht
news:el**************@TK2MSFTNGP03.phx.gbl...
嗯,,,: - |
Hmmm ,,, :-|
如果你已经在你的VB6转换程序中使用了模块,那么永远不会有理由使用模块execpt。
There is never a reason to use a module execpt if you have that already
in your VB6 converted program.


这只是你的意见Cor

回答你的问题Bonzol

VB.Net中的模块是什么?

VB中的模块。 Net =每个成员隐含地理解共享的类。当使用
成员时,不需要提供模块名称。

模块编译为NotInheritable类,附加名为StandardModuleAttribute的属性。就编译的代码而言,
没有区别。

然而,这也是为什么整个OOP阵营中的人们说你不应该使用的原因模块
一个NotInheritable(密封)类只包含Shared(静态)
方法,不是很好的面向对象设计。 :-)

在我看来,有两种情况使用模块可能有效

1.你不关心OOP规则而只是想要尽可能快地编写
尽可能简单的程序在某种情况下你的意见是否有效使用模块(这是一种风格的东西)我个人
包装一个类中的所有东西都可以表示为一个对象
(一个模块可以为你节省很多打字)

2.当你想要覆盖VB的标准方法调用行为时。 net

喜欢更好的IIF

公共功能IIf(Of T)(ByVal表达式为布尔值,_
ByVal truePart为T,ByVal falsePart为T)As T

如果表达那么

返回truePart

其他

返回falsePart

结束如果

结束功能

这在一个模块中会对代码中的iif进行匿名调用,重定向到仿制药,所以在这种情况下,这是一个很好的功能)

问候语米歇尔波塞斯[MCP]


/>Cor Ligthert [MVP] <无************ @ planet.nl> schreef in bericht
新闻:OJ ************** @ TK2MSFTNGP02.phx.gbl ...



That is just your opinion Cor

To answer your question Bonzol

What is a module in VB.Net ?

A Module in VB.Net = a Class where Shared is implicitly understood
for each member. And the module name doesn''t need to be supplied when the
members are used.

A Module compiles down to a NotInheritable class, with an attribute
called StandardModuleAttribute attached. As far as the compiled code goes,
there''s no difference.

However here is also the catch why people in the full OOP camp say you
shouldn`t use modules
a NotInheritable(sealed) class which only consists of Shared (static)
methods is not very good object-oriented design. :-)

In my opinion there are two situations in wich using a Module might be
valid

1. You do not care about OOP rules and just want to write as fast as
possible and as easy as possible a program in a situation were it is in
your opinion valid to use a module ( it''s a style thingy ) i personally
wrap everything in a class when it can be represented as an object
( a module can save you a lot of typing )

2. when you want to override the standard method call behavior of VB.net

like a better IIF

Public Function IIf(Of T)(ByVal expression As Boolean, _
ByVal truePart As T, ByVal falsePart As T) As T

If expression Then

Return truePart

Else

Return falsePart

End If

End Function

This in a module will make anny call to iif in your code be redirected to
this "better" iif method so instead of having to change all your code you
can take advantage of language enhancements in the future by just writing
better methods as the language features ( in previous versions we did not
have generics , so in this situation it is a nice feature to have )

regards

Michel Posseth [MCP]



"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:OJ**************@TK2MSFTNGP02.phx.gbl...

Bonzol,
在这个新闻组中有一千次询问问题。

模块是一个只有共享成员的类的简单格式。

没有理由使用模块execpt,如果你已经在你的VB6转换程序中已经


如果你想了解更多,请尝试在Google新闻组中搜索它。

http://groups.google.com/group/micro...rch+this+group
然而,请再次提出这类问题。你不可能知道它经常被问到。

我希望这能给出一个想法

Cor

" Bonzol" <博**** @ hotmail.com> schreef in bericht
新闻:11 ********************** @ p79g2000cwp.googlegr oups.com ...
Bonzol,

One of the thousand times asked question in this newsgroup.

A module is a simple format of a Class with only Shared members.

There is never a reason to use a module execpt if you have that already
in your VB6 converted program.

If you want to know more try a search on that in Google Newsgroups.

http://groups.google.com/group/micro...rch+this+group

However feel free to ask this kind of questions again. You could not have
knowed that it is so often asked.

I hope that this gives an idea

Cor

"Bonzol" <Bo****@hotmail.com> schreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...
vb.net

嘿那里,有人可以告诉我
类和模块之间的差异,以及何时使用它们与
其他相比?

任何帮助都会很棒

Thanx提前
vb.net

Hey there, could someone just tell me what the differnce is between
classes and modules and when each one would be used compared to the
other?

Any help would be great

Thanx in advance





这篇关于类和模块之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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