Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Last active August 29, 2015 14:02
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/4e5ad5511c1957244693 to your computer and use it in GitHub Desktop.
Save Fhernd/4e5ad5511c1957244693 to your computer and use it in GitHub Desktop.
Demostración del delegado genérico Func<TResult>(out TResult) en C#.
using System;
using System.IO;
namespace Articulos.Cap04
{
public class ConFunc
{
public static void Main()
{
SalidaContenido sc = new SalidaContenido();
// Uso de Func<TResult>(out TResult):
Func<bool> delFunc = sc.EnviarAArchivo;
if (delFunc())
{
Console.WriteLine("La escritura fue satisfactoria.");
}
else
{
Console.WriteLine("La escritura ha fallado.");
}
}
}
public class SalidaContenido
{
public bool EnviarAArchivo()
{
try
{
StreamWriter sw = new StreamWriter("output1.txt");
sw.WriteLine("Blog xCSw");
sw.Close();
return true;
}
catch
{
return false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment