// Employees now have benefits.
partial class Employee
{
// Contain a BenefitPackage object.
protected BenefitPackage empBenefits = new BenefitPackage();
...
}
At this point, you have successfully contained another object. However, to expose the function-
ality of the contained object to the outside world requires delegation.
Delegation is simply the act of
adding members to the containing class that make use of the contained object’s functionality. For
example, we could update the Employee class to expose the contained empBenefits object using a
custom property as well as make use of its functionality internally using a new method named
GetBenefitCost():
public partial class Employee
{
// Contain a BenefitPackage object.
protected BenefitPackage empBenefits = new BenefitPackage();
Do'stlaringiz bilan baham: |