Doubt in Parent-Child relations

Doubt in Parent-Child relations

Old forum URL: forums.lhotka.net/forums/t/8102.aspx


alagesan posted on Sunday, December 06, 2009

hi.,
i created parent-child relationship based classes using CSLA
i added child class as a property in parent class

now i want access parent class field in child class
how do i get the parent fields?
 i can able to access child fields in parent class
 but i cant to do access in child class

RockfordLhotka replied on Sunday, December 06, 2009

One object can not (and should not) access another object's fields. That breaks encapsulation and is terrible programming.

But you might be asking if the child can access the parent's properties, and that is fine. You just need to cast the Parent property to the type of the parent object, otherwise it is IParent, which isn't useful.

Copyright (c) Marimer LLC