0% found this document useful (0 votes)
21 views2 pages

Push Pop Codigo C#

The document demonstrates using a stack data structure in C# by pushing and popping elements onto and off of the stack and checking for elements contained in the stack.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Push Pop Codigo C#

The document demonstrates using a stack data structure in C# by pushing and popping elements onto and off of the stack and checking for elements contained in the stack.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
//Console.WriteLine("Hello World!");
Stack _Pila = new Stack();
//PUSH
Console.WriteLine("----PUSH----");
_Pila.Push("Jose");
_Pila.Push("Fernando");
_Pila.Push("Herrera");
_Pila.Push("Escobar");
_Pila.Push("5090");
_Pila.Push("20");
_Pila.Push("3170");
foreach (var oElemento in _Pila)
{
Console.WriteLine(oElemento);
}
Console.ReadKey();

//Ejmplo
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("----Ejemplo Pila----");
Console.WriteLine("Elementos en la pila Actualmente " + _Pila.Count);

Console.WriteLine("Ingrese un Valor para buscarlo....");


string _BucarStack = Console.ReadLine();
Console.WriteLine("El Stack contiene el elemento " +_BucarStack + " = "
+ _Pila.Contains(_BucarStack));
Console.ReadKey();
Console.WriteLine(); Console.WriteLine();

//POP
Console.WriteLine("----POP----");
Console.WriteLine("Removiendo Valores....");
_Pila.Pop();
Console.WriteLine("----POP1----");
foreach (var oElemento in _Pila)
{
Console.WriteLine(oElemento);
}
_Pila.Pop();
Console.WriteLine("----POP2----");
foreach (var oElemento in _Pila)
{
Console.WriteLine(oElemento);
}
_Pila.Pop();
Console.WriteLine("----POP3----");
foreach (var oElemento in _Pila)
{
Console.WriteLine(oElemento);
}
_Pila.Pop();
Console.WriteLine("----POP4----");
Console.WriteLine("Elementos en la pila Actualmente " + _Pila.Count);
foreach (var oElemento in _Pila)
{
Console.WriteLine(oElemento);
}
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy