I am playing around with delegates and I came to the situation where I am not sure what is going on.
In my logic, invocation list of "greetings" delegate should return 2, but it just returns 1. As you can see, I am passing the delegate reference to the object I created. I wanted to confirm that delegate can reference private methods from outside and only requirement is that the method is accessible during the assigment of method to the delegate.
class Program { static void Main(string[] args) { Action greetings = FirstGreeting; Test test = new Test(); test.AddGreeting(greetings); Console.WriteLine(greetings.GetInvocationList().Count()); greetings(); Console.ReadLine(); } static void FirstGreeting() { Console.WriteLine("This is the first greeting."); } } class Test { public void AddGreeting(Action greetings) { greetings += new Action(SecondGreeting); } private void SecondGreeting() { Console.WriteLine("This is the second greeting."); } }