Created
May 31, 2014 19:16
-
-
Save Fhernd/82c91e7441b2169d8639 to your computer and use it in GitHub Desktop.
Demostración de la declaración de un delegado personalizado en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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