如何在代码中实现聚合和关联?

时间:2018-09-23 08:28:32

标签: java c# associations aggregation

代码中的聚合关联是什么?(Java或C#)
我找不到“聚合和关联”的代码示例。

1 个答案:

答案 0 :(得分:1)

协会示例:员工有地址

public class Employee  
{         
   public Address address; //Employee HAS-A Address  
}

汇总示例:员工有很多地址

public class Employee  
{         
  public List<Address> address; //Employee HAS-Many Address  
}

请参阅:C# code for association, aggregation, composition