Last active
December 24, 2015 11:09
-
-
Save Fhernd/6788915 to your computer and use it in GitHub Desktop.
Demostración de la sentencia repetitiva foreach en C#.
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
class PruebaForeach | |
{ | |
static void main() | |
{ | |
string[] diasSemana = { "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo" }; | |
// imprime los valores del arreglo de cadenas de caracteres diasSemana | |
foreach (string dia in diasSemana) | |
{ | |
Console.WriteLine (dia); | |
} | |
Console.WriteLine (); // imprime línea en blanco | |
List<int> listaPrimos = new List<int>(); | |
listaNumeros.Add(2); | |
listaNumeros.Add(3); | |
listaNumeros.Add(5); | |
listaNumeros.Add(7); | |
listaNumeros.Add(11); | |
// impresión del contenido de la lista de enteros de 32 bits | |
foreach (int primo in listaPrimos) | |
{ | |
Console.WriteLine(primo); | |
} | |
Console.WriteLine (); // imprime línea en blanco | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment