let say i have following class:
class Shape
{
public int widht;
public List<Point> points;
}
and in class Point i want to use this widht property from class Shape, so if “point” belong to that list i wish to have possibility to use “container” properties. I also want to serialize then class Shape so I don’t think i can use constructor with parameters.
Edit:
I will say how it looks like in my app:
i have class Device
class Device
{
string connection;
List<Task> tasks;
}
and Task
class Task
{
void DoTask()
{
and here i need the connection
}
}
so i just like to do it then foreach(task in task) task.DoTask() but i have to pass additional “this” like task.DoTask(this) or the connection where i think that i should have acces of my container if it allows me.
There’s no general concept of the “owner” of an object. After all, the same
Pointreference could appear in several places. The desire to do this usually indicates a design smell. If you need to give thePointobject more information, that’s presumably when you’re doing something with it – so pass that information to the appropriate method.