-
-
Save parzibyte/35c151a70e50e1224bd281fd09da9a5d to your computer and use it in GitHub Desktop.
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; | |
/* | |
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