Queue

Design Window

Source Code




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;
using System.Collections;

namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
Queue q = new Queue();

public Form1()
{
InitializeComponent();
}

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

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);
}
}
}
}


Output


No comments:

Post a Comment