Advertisement
Fhernd

TresMaestrosGenericos.cs

Oct 22nd, 2017
12,663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace cap07.colecciones
  5. {
  6.     class TresMaestrosGenericos
  7.     {
  8.         public static void Main()
  9.         {
  10.             // Creación de un objeto Stack:
  11.             Stack<string> tresMaestros = new Stack<string>();
  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<string> coleccion)
  22.         {
  23.             foreach(string 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