Answer the question
In order to leave comments, you need to log in
Is it possible to add a method to a delegate that was received via an out parameter?
Hello. A bit of pseudocode. In one class, I have a dictionary with delegates, and a method that finds the desired delegate, this class also invokes these delegates
public bool TryFind(string name, out Action action)
{
action = dictionary[name];
}
public bool AddMethod()
{
if(TryFind("a", out var value)
{
value += methodA;
}
}
Answer the question
In order to leave comments, you need to log in
With this approach, you have a class encapsulation violation.
Through the methods of the class in which the delegates are stored and you need to add methods to the delegates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question