how to use queue concept in C#

Posted by Raj_Chennai under C# on 3/17/2012 | Points: 10 | Views : 2216 | Status : [Member] | Replies : 6
how to use queue concept in C#.Give me the example

raj


Responses

Posted by: Hmanjarawala on: 3/17/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi try this:

http://www.codeproject.com/Articles/12399/Specialized-Queues-A-Cyclic-Queue

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Raj_Chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/17/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Raj,
For your reference:
http://dng-collections.blogspot.in/2007/05/queue-concept-in-net.html


Thanks,
Sanjay

Raj_Chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 3/18/2012 [Member] Starter | Points: 25
Posted by: Sabarimahesh on: 3/19/2012 [Member] Bronze | Points: 25

Up
0
Down
Queue Number= new Queue();

Number.Enqueue("one");
Number.Enqueue("two");
Number.Enqueue("three");

if (Number.Contains("three"))
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Raj_Chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/20/2012 [Member] Bronze | Points: 25

Up
0
Down
You can use Enque and Deque method of Queue Class in C#

Queue queue = new Queue();
queue.Enqueue("abc");
queue.Enqueue("xyz");
queue.Enqueue("lmn");
Console.WriteLine(queue.Dequeue());

Thanks,
Rajni Shekhar

Raj_Chennai, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Veerac85 on: 3/22/2012 [Member] Starter | Points: 25

Up
0
Down
it's pretty straight forward

Queue<int> list = new Queue<int>();

to add items to the queue
list.Enqueue(1);
list.Enqueue(2);

to process (& remove) items from the queue
int firsitem = list.Dequeue();

if you just want to take a peek
int topitem = list.Peek();

if you want to see a full blown example, you could visit http://technico.qnownow.com/2012/03/22/using-queues-for-real-time-applications-in-c/

Raj_Chennai, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response