hello everyone, just started learning the delegates. There is an example:
// Класс, метод которого будет сообщен с делегатом. static class MyClass { // Создаем статический метод, который планируем сообщить с делегатом. public static void Method() { Console.WriteLine("Строку вывел метод сообщенный с делегатом."); } } // На 21-й строке создаем класс-делегата с именем MyDelegate, // метод, который будет сообщен с экземпляром данного класса-делегата, // не будет ничего принимать и не будет ничего возвращать. public delegate void MyDelegate(); // Создаем класс делегата. (1) class Program { static void Main() { MyDelegate myDelegate = new MyDelegate(MyClass.Method); // Создаем экземпляр делегата. (2) myDelegate.Invoke(); // Вызываем метод сообщенный с делегатом. (3) myDelegate(); // Другой способ вызова метода сообщенного с делегатом. (3') // Delay. Console.ReadKey(); } } pay attention to this line:
public delegate void MyDelegate(); // Создаем класс делегата. (1) This course is provided in the form of video lessons, the author says the following:
"note that the method (the default constructor in our delegate class) that will be communicated with this instance of this delegate class - should not accept anything , and also should not return anything "
Here is my question: what the default constructor of the delegate class is: should not accept anything, and should not return anything either "is an axiom for all delegates when created , or is it a specific case because this delegate is In this case, reported with this method:
public static void Method() { Console.WriteLine("Строку вывел метод сообщенный с делегатом."); } which takes nothing as parameters and is void; that is, returns nothing, and has this method affected the principles of constructing the delegate and the parameters of its constructor? Ie in the end it's either
common axiom
specific case of constructing a delegate class reported with this method
Here, in response, I want to get an explanation and an answer, which of the two options is correct.