I have a whole type stack in the console of c # and I want to delete an element inside it, the element must be written by the user, for example: If I have the data in the stack: 12, 34, 54, 6, 44, a message will appear on the screen: "Enter the data you want to delete", if the user enters 44, the stack should be displayed without the data. I'm doing it with the Pop method but I have a problem, pop just deletes the first data, I want you to delete a specific data
THIS METHOD ONLY ERASES THE FIRST FACT:
public void usePop()
{
showStackElements();
Console.WriteLine("Ingrese el valor que desea eliminar");
int valor = (int)stack.Pop();
Console.WriteLine("Elemento " + valor + " eliminado");
}
I have modified the code trying to save a variable (value) and I have entered that variable in the stack.Pop (value) method but it gives me an error.
CODE WITH ERROR:
public void usePop()
{
showStackElements();
Console.WriteLine("Ingrese el valor que desea eliminar");
int valor = Convert.ToInt32(Console.ReadLine());
stack.Pop(valor);
Console.WriteLine("Elemento " + valor + " eliminado");
}
Thank you.