Created
October 22, 2017 16:00
-
-
Save Fhernd/2873d18d170e6f4ca3ef7328f1d928ee to your computer and use it in GitHub Desktop.
Versión de Stack en genéricos.
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.Collections.Generic; | |
namespace cap07.colecciones | |
{ | |
class TresMaestrosGenericos | |
{ | |
public static void Main() | |
{ | |
// Creación de un objeto Stack: | |
Stack<string> tresMaestros = new Stack<string>(); | |
tresMaestros.Push("Dostoievskiy"); | |
tresMaestros.Push("Balzac"); | |
tresMaestros.Push("Dickens"); | |
Console.WriteLine("Número de elementos: {0}", tresMaestros.Count); | |
Console.WriteLine("Elementos: "); | |
ImprimirContenido(tresMaestros); | |
} | |
public static void ImprimirContenido(IEnumerable<string> coleccion) | |
{ | |
foreach(string escritor in coleccion) | |
{ | |
Console.Write(" {0}", escritor); | |
} | |
Console.WriteLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment