Skip to main content

Non Generic Collection:Queue


Non Generic Collection:QueueQueue:non generic collection
An introduction to DOT NET:
Non generic collection: Queue
The non-generic collection classes store data of type Object.
queue is FIFO first come first served .
Here queue is used to save data and retrieved it in FIFO manner.
You can run program and see the working procedure of it.

Non Generic Collection:Queue


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 queuecollectionprogram
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            label1.Text = "";
        }
        Queue qq = new Queue();
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            label1.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = "";
            if (textBox1.Text == "")
            {

                MessageBox.Show("Enter value in textbox");

            }
            else
            {
                qq.Enqueue(textBox1.Text);
                show();
                MessageBox.Show(textBox1.Text + "   inserted");
            }
        }
        public void show()
        {
            listBox1.Items.Clear();
            foreach (Object obj in qq)
            {
                listBox1.Items.Add(obj);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (qq.Count <= 0)
            {

                MessageBox.Show("queue is emplty");
            }
            else
            {
                label1.Text = qq.Dequeue().ToString();
                show();
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            label1.Text = "";
            if (qq.Count <= 0)
            {

                MessageBox.Show("queue is empty");
            }
            else {
                label1.Text = "peek element is:" + qq.Peek().ToString();
                show();
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            label1.Text = "";
            MessageBox.Show("Total queue element is  " + qq.Count.ToString());
        }

        private void button4_Click(object sender, EventArgs e)
        {
            label1.Text = "";
            if (qq.Count <= 0)
            {

                MessageBox.Show("queue is empty");
            }
            else {

                if (qq.Contains(textBox2.Text))
                {


                    MessageBox.Show("available");
                }
                else {

                    MessageBox.Show("Not available");
                }
            }
        }
    }
}








Posted By:Tanuj Kumar 
On:Shareyourconscience



Comments

Popular posts from this blog

Join the Beauty Course for Massage Beauty License Training

Massage Beauty School of California: Massage beauty program is one of the top ten beauty courses which are well recognized and sought after in the beauty sector. Several students from various cities and states enroll in this training program to get better learning opportunities and understand the minute technicalities of beauty massaging services. Certified schools and beauty institutes located in Los Angeles are offering cutting-edge training to the students who are eligible for the program. Palace Beauty College is an accredited beauty school that does offer a massage therapy program and also offers holistic learning facilities to the students. The college has years of experience in providing massage therapy license training in Los Angeles for more than half a decade now. The college maintains its official website to reach out to distant students and provide them relevant information related to the available beauty courses. The college takes pride in its impressive infrastru...

Former President APJ Abdul Kalam Died at 83

"Missile Man is no more" A.P.J Abdul Kalam died in Shillong. He was brought into the hospital without a pulse or BP. There was no sign of life John Sailo Ryntathiang, director of Bethany Hospital," told the Quint. About Abdul Kalam: Abdul Kalam was an Indian scientist who was the 11th President of India from 2002 to 2007. Kalam was born and raised in Rameswaram(Tamil Nadu) and studied physics and aerospace engineering. He worked as a scientist and science administrator, mainly at the Defence Research and Development Organisation (DRDO) and Indian Space Research Organisation (ISRO) before he became president. The Centre has declared national mourning for seven days. Kalam served as president for five years from 2002, enjoying the support of both the ruling BJP and the opposition Congress. He graduated from Saint Joseph's College, Tiruchirappalli in 1954 but not satisfied with his degree, he left for Madras later next year to study aerospace engineering. He enrolled ...

Cryptocurrency: The future currency and bitcoin investment

What is Cryptocurrency? Cryptocurrency is a digital or virtual currency that uses cryptography for security. A cryptocurrency is a medium of exchange that uses cryptography to secure transactions and control the creation of additional units. Cryptocurrency uses a decentralized system of records called a blockchain to track transactions instead of using a traditional database like a conventional currency. The crypto world is full of surprises. New coins and tokens are being launched almost every day. Some of these go on to change the world, while others will fizzle out and be forgotten. It’s impossible to predict which ones will thrive and which ones will fail, but crypto is a great way to keep up with the latest developments in technology and finance. Cryptocurrency is a digital or virtual currency that uses cryptography for security. A cryptocurrency is difficult to counterfeit because of this security feature. A defining feature of a cryptocurrency, and arguably its most alluring ass...