Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created September 30, 2014 03:14
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/85a7ecaa546d1458396f to your computer and use it in GitHub Desktop.
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.
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