Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created October 22, 2017 15:40
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/449cabd17cc4e8d5fea8b8efef6473e0 to your computer and use it in GitHub Desktop.
Save Fhernd/449cabd17cc4e8d5fea8b8efef6473e0 to your computer and use it in GitHub Desktop.
Uso de la clase System.Collections.Stack.
using System;
using System.Collections;
namespace cap07.colecciones
{
class TresMaestros
{
public static void Main()
{
// Creación de un objeto Stack:
Stack tresMaestros = new Stack();
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 coleccion)
{
foreach(Object 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