Instantly share code, notes, and snippets.

Embed
What would you like to do?
Codigo de ejemplo del post sobre delegados de la pagina web tallerdeprogramacion.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Eventos
{
public delegate void WorkPerformedHandler(int hours, int type);
class Program
{
static void Main(string[] args)
{
WorkPerformedHandler del1 = new WorkPerformedHandler(WorkPerformed1);
WorkPerformedHandler del2 = new WorkPerformedHandler(WorkPerformed2);
WorkPerformedHandler del3 = new WorkPerformedHandler(WorkPerformed3);
del1 += del2;
del1 += del3;
del1(5, 1);
Console.ReadKey();
}
static void WorkPerformed1(int hoursWorked, int typeWork)
{
Console.WriteLine("llamado metodo WorkPerformed1");
}
static void WorkPerformed2(int hoursWorked, int typeWork)
{
Console.WriteLine("llamado metodo WorkPerformed2");
}
static void WorkPerformed3(int hoursWorked, int typeWork)
{
Console.WriteLine("llamado metodo WorkPerformed3");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment