There is a class A in which the variables k, k2, kn are declared. You must pass a delegate to this class with code that interacts with class A variables. Class B is used for this. The problem is that class A is not visible from the delegate code inside class B, and such code cannot be passed to the class. How to decide if resolved at all possible?
class A { public int k; public int k2; ... public in kn; public delegate void Delegate1(); private Delegate1 Delegate; public A(Delegate1 GiveDelegate) { this.Delegate = GiveDelegate; this.Delegate(); } } class B { // ΠΊΠΎΠ΄ ΠΊΠ»Π°ΡΡΠ° B public void interactWithA(int GiveInt) { A Test = new A(delegate(){ k = GiveInt; //ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ Π΄Π΅ΠΉΡΡΠ²ΠΈΠΉ Ρ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠΌΠΈ }); } // ΠΊΠΎΠ΄ ΠΊΠ»Π°ΡΡΠ° B }
Band pass classBto the constructor of classAAnd in classΠsigned up as a delegate to a classBevent. If so delegates are necessary. Or use thepublic void SetK(int newK){k=newK;}methodpublic void SetK(int newK){k=newK;}- Dmitry Chistik