What I’m trying to do is:
public static Action<string> action_thread_ended { get; private set; }
public static void action_set(Action<string> target, Action<string> source)
{
target += source;
}
Usage (from different class)
MyClassName.action_set(MyClassName.action_thread_ended, Console.WriteLine);
Result: Nothing
I am of course trying to do this to prevent having to make an action_set function for each Action in the class.
Is this possible?
Delegates are immutable.
target += sourcecreates a new delegate instance, and makes thetargetparameter refer to it.The property that you passed is not affected.