班级中的班级 [英] Class in a Class

查看:75
本文介绍了班级中的班级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将一个类定义为另一个类的一部分有什么好处

定义(嵌套类)?

What are the advantages of defining a class as part of another class
definition (nesting classes)?

推荐答案

主要是范围和整洁。有些课程并不属于其他地方。


-


OHM(Terry Burns)

。 。 。单手人。 。

如果你需要我的电子邮件,请问我


当你不知道自己在做什么时,过得很快


" Scott M." < S - *** @ nospam.nospam>在消息中写道

新闻:OC ************* @ TK2MSFTNGP11.phx.gbl ...
Mainly scope and tidyness. Some classes dont really belong anywhere else.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don''t know what you''re doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
定义有什么好处一个类作为另一个类
定义(嵌套类)的一部分?
What are the advantages of defining a class as part of another class
definition (nesting classes)?



Scott,

当嵌套类是外层类的

实现细节时,我会将一个类嵌套在另一个类中。


例如,LinkedList类的Node类。 Node类保存

实际链接。在链表中。


公共类LinkedList


私有类节点

Public Next As Node

Public Previous As Node

公共数据作为对象

结束班级


...


结束类


LinkedList的各种方法,例如Add,创建一个新的Node类,并且

将数据添加到它。 Node类包含之前的&接下来引用

到列表中的其他节点。


希望这有帮助

Jay


" Scott M." < S - *** @ nospam.nospam>在消息中写道

新闻:OC ************* @ TK2MSFTNGP11.phx.gbl ...
Scott,
I will nest one class inside another when the nested class is an
implementation detail of the outer class.

For example, the Node class of a LinkedList class. The Node class holds the
actual "links" in the linked list.

Public Class LinkedList

Private Class Node
Public Next As Node
Public Previous As Node
Public Data As Object
End Class

...

End Class

The various methods of LinkedList, such as Add, creates a new Node class and
adds the data to it. The Node class contains the previous & next references
to the other nodes in the list.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
定义有什么好处一个类作为另一个类定义(嵌套类)的一部分?
What are the advantages of defining a class as part of another class
definition (nesting classes)?



*" Scott M." < S - *** @ nospam.nospam> scripsit:
* "Scott M." <s-***@nospam.nospam> scripsit:
将一个类定义为另一个类
定义(嵌套类)的一部分有什么好处?
What are the advantages of defining a class as part of another class
definition (nesting classes)?




"优点"取决于嵌套类的修饰符及其

构造函数。我建议看一下在.NET Framework中使用嵌套类的地方




-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://dotnet.mvps.org / dotnet / faqs />



The "advantages" depend on the modifier of the nested class and its
constructor. I suggest to take a look at where nested classes are used
inside the .NET Framework.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


这篇关于班级中的班级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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