Created
May 22, 2014 15:39
-
-
Save Fhernd/d7f28830f6b5d27d5da7 to your computer and use it in GitHub Desktop.
Creación de una clase genérica.
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
// ===++=== | |
// | |
// OrtizOL | |
// | |
// ===--=== | |
/*============================================================ | |
// | |
// Clase: Pila.cs | |
// | |
// Propósito: Creación de una clase genérica. | |
// | |
============================================================*/ | |
using System; | |
namespace Articulos.Cha03 | |
{ | |
internal class Pila<T> | |
{ | |
// Posición de un elemento en la pila: | |
private int posicion; | |
// Elementos de datos como un arreglo estándar: | |
private T[] datos = new T[100]; | |
// Constructor: | |
public Pila() | |
{ | |
posicion = 0; | |
} | |
// Coloca un elemento de dato en la pila: | |
public void Push(T elemento) | |
{ | |
datos[posicion++] = elemento; | |
} | |
// Retira un elemento de dato de la pila: | |
public T Pop() | |
{ | |
return datos[--posicion]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment