Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 1, 2019 22:13
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 parzibyte/35c151a70e50e1224bd281fd09da9a5d to your computer and use it in GitHub Desktop.
Save parzibyte/35c151a70e50e1224bd281fd09da9a5d to your computer and use it in GitHub Desktop.
using System;
/*
Invertir un arreglo en C#
Demostración con arreglo de cadenas pero también funciona
para otros tipos de arreglos
@author parzibyte
Visita: parzibyte.me/blog
*/
class MainClass {
public static void Main (string[] args) {
string[] lenguajes = {"C#", "C", "C++","Go","Java","PHP","JavaScript", "Python"};
Console.WriteLine("========\nImprimiendo arreglo antes de invertir\n========");
foreach(string lenguaje in lenguajes){
Console.WriteLine(lenguaje);
}
// La siguiente línea invierte el arreglo:
Array.Reverse(lenguajes);
Console.WriteLine("========\nImprimiendo arreglo DESPUÉS de invertir\n========");
foreach(string lenguaje in lenguajes){
Console.WriteLine(lenguaje);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment