static void Main(string[] args) { //delegado generico Midelegado <string> delegadoString = new Midelegado <string>(HandlerString); delegadoString("juan"); Midelegado <int> delegadoInt = new Midelegado <int>(HandlerInt); delegadoInt(3); //action int numero = 5; string name = "hola a todos"; /*siempre void*/ Action <string, int> delegadoAction = new Action <string, int>(repetir); delegadoAction(name, numero); //func similiar a action pero permite retono de valor Func <int /* A */, int /* B */, int /* RETORNO ULTIMO*/> delegadoFunc = new Func <int, int, int>(suma); Console.WriteLine(delegadoFunc(3, 4)); Console.ReadKey(); }
static void Main(string[] args) { Midelegado delegado = new Midelegado(Avion.Volar); delegado("Nos vemos cuidense mucho"); delegado = new Midelegado(Auto.Rodar); delegado("Empieza la gira yeii"); Console.ReadLine(); }