Created
October 4, 2020 12:28
-
-
Save mugan86/0a7a9954c3047cb19a7de5e6695f5d05 to your computer and use it in GitHub Desktop.
Mainupular valores dentro de una pila
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
Stack<string> pages = new Stack<string>(new string[] { "index", "blog", "article-1", "article-2" }); | |
Console.WriteLine("Primera página si damos a BACK: " + pages.Peek()); | |
/*foreach (string pageHistory in pages) | |
{ | |
Console.WriteLine(pageHistory); | |
}*/ | |
pages.Pop(); | |
string [] arrayElements = pages.ToArray(); | |
arrayElements[arrayElements.Length - 1] = "contact"; | |
// Asignar el orden en el que se va a apilar para mantener el orden anterior de la pila | |
Array.Reverse(arrayElements); | |
pages = new Stack<string>(arrayElements); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment