c# 4.0 - How to find the parent object from the child(property) object in C#? -
i have situation child able reference parent. reason want child have ability update parent object.
configuration.range.next(configuration)
i not want pass parent object reference instead range object should able find parent object. how this?
class range { ....methodx(){how access configuration object here } }
class configuration { public range range{get;set;} ..... }
part of difficulty answering question people use terms "child" , "parent" mean different things different people.
one of common uses of terms synonyms subclass (child) , superclass (parent) in inheritance structure. assuming meaning, have access superclass (i.e. "parent") declared public
or protected
. example:
public class parent { protected int foo { get; set; } } public class child : parent { public void dosomething() { foo = 42; // or base.foo = 42; } }
if isn't situation you're working please add more information original question better describe mean when use terms "child" , "parent."