One to one association relationship in C# | OOP in C# Part-14



What is Association?

Association is a (*a*) relationship between two classes. It allows one object instance to cause
another to perform an action on its behalf. Association is the more general term that define the
relationship between two classes, where as the aggregation and composition are relatively
special.

One-to-One association relationship

Let's consider a simple example of a One-to-One relationship, when both classes that participate in the relationship have properties with a reference to the instance of their opposite class. It's necessary to write extra code within the property's setter method for each class that participates in the relationship to ensure the relationship's integrity, i.e. when a new object is assigned to a reference property, the reference to the previous object instance should be cleared and the assigned object should reference the current one.

Post a Comment

Previous Post Next Post