Created
June 10, 2014 21:27
-
-
Save Fhernd/d9f6cddeb6defe51c678 to your computer and use it in GitHub Desktop.
Demostración básica del uso de LINQ en tres pasos: (1) especificación de la fuente, (2) diseño de la consulta, y (3) la ejecución de la consulta.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
namespace Articulos.Cap04 | |
{ | |
public sealed class IntroLINQ | |
{ | |
public static void Main() | |
{ | |
// Partes fundamentales para hacer uso de LINQ> | |
// 1. La fuente de datos> | |
int[] numeros = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }; | |
// 2. Creación de la consulta: | |
var numerosConsulta = from num in numeros where (num % 2) == 0 select num; | |
// 3. Ejecución de la consulta: | |
foreach (int numero in numerosConsulta) | |
{ | |
Console.WriteLine( "{0,1}", numero.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment