I have a plain normal class, e.g.:
public class ObjectA
{
public string val {get;set;}
...
}
in another class, it holds an instance of ObjectA, e.g.:
public class ObjectB
{
private ObjectA objectA;
....
}
the instance “objectA” will be frequently changed.
i mean in ObjectB, some of the method will new and new instance of Object A and assign to “objectA”
is there a way to implement a trigger, whenever instance objectA is change, will allow me to do something, e.g.:
objectA += OnChanged_ObjectA
protected void OnOnChanged_ObjectA()
{
// do something
}
You can create a change event on
ObjectAthat you will fire for any of the changes you wish to track. This will allow you to subscribe to this event on any other object, includingObjectB.In
Object1.cs:And in
Object2.csyou can subscribe: