C#类中的关系 [英] relations in c# classes

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

问题描述



如何保持关系之间的关系,

有多少种关系船,

如何创建一对一和一对多.



问候
upen

Hi,

how to keep relations ships between clases,

how many types of relation ship ,

how to create one to one and one to many.



Regards
upen

推荐答案

在OO中,有许多重要的关系类型,仅举几例
-聚合:一个类引用另一个类,但该类不具有所引用类的所有权
-组成:一个类引用了另一个类,并拥有所引用类的所有权
-继承:这是是"关系.

另一个方面是基数.例如,如果一个类包含另一个类的数组,则基数为*或数组的最大维数.

但这都是非常基本的东西.如果您不了解所有这些,那么您应该真正阅读一本关于OO编程的好书.也许甚至是UML,因为UML全部涉及静态和动态类之间的关系.
In OO there are many important types of relationships to name a few
- aggregation : a class refers to another one, but the class has no ownership of the referred class
- composition : a class refers to anothr one, and has ownership of the referred class
- inheritance : this is a "is a" relationship.

Another aspect is the cardinality. If a class contains for instance an array of another class the cardinality is * or max dimention of the array.

But this is all pretty basic stuff. If you don''t know all this you should really read a good book about OO programming in general. Perhaps even UML because UML is all about relationships between classes both statically and dynamically.


这确实是一个基本问题,您可以通过查看Microsoft的Visual Studio手册来找到答案. :
http://msdn.microsoft.com/en-us/library/x9afc042.aspx [ ^ ]

所以我想它回到了基础:)
This is really a basic question that you could finmd the answer to by looking in Microsoft''s Visual Studio manual:
http://msdn.microsoft.com/en-us/library/x9afc042.aspx[^]

So I guess its back to basics :)


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

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