Association, Composition and Aggregation in C#

CsharpServer Side ProgrammingProgramming

Association in C#

The association defines the relationship between an object in C#. An a one-to-one, one-to-many, many-to-one and many-to-many relationship can be defined between objects.

For example, An Employee can be associated with multiple projects, whereas a project can have more than one employee.

Composition in C#

Under Composition, if the parent object is deleted, then the child object also loses its status.

The composition is a special type of Aggregation and gives a part-of relationship.

For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.

Aggregation in C#

Aggregation is a direct relation between objects in C#. It is the relationship between objects.

For example, Employee and Department.

An Employee is associated with a single Department, whereas a Department can have more than one employee

raja
Published on 24-Jul-2018 08:37:11
Advertisements