Created
September 30, 2014 03:14
-
-
Save Fhernd/85a7ecaa546d1458396f to your computer and use it in GitHub Desktop.
Uso del método de extensión `OrderBy` de LINQ para ordenar los elementos de un arreglo de enteros.
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 Articulo.CSharp.MetodosExtension | |
{ | |
public sealed class MetodoExtensionOrderBy | |
{ | |
public static void Main() | |
{ | |
// Declaración e inicialización de un arreglo de enteros: | |
int[] enteros = {29, 13, 2, 5, 7, 37, 71}; | |
// Ordenamiento de los elementos: | |
var arregloOrdenado = enteros.OrderBy ( num => num); | |
Console.WriteLine (); | |
foreach (var num in arregloOrdenado) | |
{ | |
Console.Write ("{0}\t", num.ToString()); | |
} | |
Console.WriteLine (Environment.NewLine); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment