Advertisement
Fhernd

SinFunc.cs

Jul 26th, 2014
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. namespace Articulos.Cap04
  5. {
  6.     public delegate bool Escribir();
  7.    
  8.     public class SinFunc
  9.     {
  10.         public static void Main()
  11.         {
  12.             SalidaContenido sc = new SalidaContenido();
  13.             Escribir delegadoEscribir = sc.EnviarAArchivo;
  14.            
  15.             if (delegadoEscribir())
  16.             {
  17.                 Console.WriteLine("La escritura fue satisfactoria.");
  18.             }
  19.             else
  20.             {
  21.                 Console.WriteLine("La escritura ha fallado.");
  22.             }
  23.         }
  24.     }
  25.    
  26.     public class SalidaContenido
  27.     {
  28.         public bool EnviarAArchivo()
  29.         {
  30.             try
  31.             {
  32.                 StreamWriter sw = new StreamWriter("output.txt");
  33.                 sw.WriteLine("Blog xCSw");
  34.                 sw.Close();
  35.                 return true;
  36.             }
  37.             catch
  38.             {
  39.                 return false;
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement