Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created May 31, 2014 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/82c91e7441b2169d8639 to your computer and use it in GitHub Desktop.
Save Fhernd/82c91e7441b2169d8639 to your computer and use it in GitHub Desktop.
Demostración de la declaración de un delegado personalizado en C#.
using System;
using System.Windows.Forms;
namespace Articulos.Cap04
{
// Declaración explícita del delegado:
public delegate void MostrarValor();
public class Nombre
{
private string contenido;
public Nombre(string Nombre)
{
this.contenido = Nombre;
}
public void MostarEnConsola()
{
Console.WriteLine(this.contenido);
}
public void MostarEnVentana()
{
MessageBox.Show(this.contenido);
}
}
public class testTestDelegate
{
public static void Main()
{
Nombre nombre = new Nombre("John Ortiz Ordoñez");
MostrarValor del = nombre.MostarEnVentana;
del();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment