Advertisement
Fhernd

TresMaestros.cs

Oct 22nd, 2017
12,695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3.  
  4. namespace cap07.colecciones
  5. {
  6.     class TresMaestros
  7.     {
  8.         public static void Main()
  9.         {
  10.             // Creación de un objeto Stack:
  11.             Stack tresMaestros = new Stack();
  12.             tresMaestros.Push("Dostoievskiy");
  13.             tresMaestros.Push("Balzac");
  14.             tresMaestros.Push("Dickens");
  15.            
  16.             Console.WriteLine("Número de elementos: {0}", tresMaestros.Count);
  17.             Console.WriteLine("Elementos: ");
  18.             ImprimirContenido(tresMaestros);
  19.         }
  20.        
  21.         public static void ImprimirContenido(IEnumerable coleccion)
  22.         {
  23.             foreach(Object escritor in coleccion)
  24.             {
  25.                 Console.Write(" {0}", escritor);
  26.             }
  27.            
  28.             Console.WriteLine();
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement