Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created October 22, 2017 16:00
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/2873d18d170e6f4ca3ef7328f1d928ee to your computer and use it in GitHub Desktop.
Save Fhernd/2873d18d170e6f4ca3ef7328f1d928ee to your computer and use it in GitHub Desktop.
Versión de Stack en genéricos.
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