Advertisement
Fhernd

SinAction.cs

Jul 26th, 2014
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace Articulos.Cap04
  5. {
  6.     // Declaración explícita del delegado:
  7.     public delegate void MostrarValor();
  8.  
  9.     public class Nombre
  10.     {
  11.         private string contenido;
  12.  
  13.         public Nombre(string Nombre)
  14.         {
  15.             this.contenido = Nombre;
  16.         }
  17.  
  18.         public void MostarEnConsola()
  19.         {
  20.             Console.WriteLine(this.contenido);
  21.         }
  22.  
  23.         public void MostarEnVentana()
  24.         {
  25.             MessageBox.Show(this.contenido);
  26.         }
  27.     }
  28.  
  29.     public class testTestDelegate
  30.     {
  31.         public static void Main()
  32.         {
  33.             Nombre nombre = new Nombre("John Ortiz Ordoñez");
  34.             MostrarValor del = nombre.MostarEnVentana;
  35.             del();
  36.        }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement