Advertisement
Fhernd

ConFunc.cs

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