Stack(Push and Pop)......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class stack : Form
{
public stack()
{
InitializeComponent();
}
Stack<int> st = new Stack<int>();
private void btnpush_Click(object sender, EventArgs e)
{
st.Push(Convert.ToInt32(textBox1.Text));
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
}
private void btnpop_Click(object sender, EventArgs e)
{
int i = st.Pop();
MessageBox.Show(i + "is poped");
int k = st.Count;
listBox1.Items.RemoveAt(k);
listBox1.Refresh();
}
}
}
Category: