C#DOTNETCONSOLEAPPLICATION

Queue




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;

namespace WindowsFormsApplication1
{
    public partial class queue : Form
    {
        Queue q = new Queue();
        public queue()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            q.Enqueue(textBox1.Text);
            textBox1.Clear();
            MessageBox.Show("Enqueued...");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                listBox1.Items.Add(q.Dequeue());
            }
                catch(Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                textBox1.Text = q.Peek().ToString();
            }
            catch (Exception er)
            {
                MessageBox.Show("Error:" +er.Message);
            }
        }
    }
}


No comments:

Post a Comment

Techzmatrix