Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 10, 2014 00:47
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/589e37a84d5f77c5bccb to your computer and use it in GitHub Desktop.
Save Fhernd/589e37a84d5f77c5bccb to your computer and use it in GitHub Desktop.
Uso de parámetros explícitos para expresiones lambda.
using System;
namespace Articulos.Cap04
{
public sealed class TiposParametrosExplicitos
{
public static void Main()
{
// Uso de delegado genérico integrado,
// Func<T, TResult>.
// El compilador hace la tarea de inferencia:
Func<int, int> cuadrado1 = x => x * x;
Console.WriteLine ("\nUso de `x => x * x`: {0}", cuadrado1(11).ToString());
// Aquí ayudamos al compilador a inferir los tipos
// de los parámetros:
Func<int, int> cuadrado2 = (int x) => x * x;
Console.WriteLine ("\nUso de `(int x) => x * x`: {0}", cuadrado1(11).ToString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment