Search results for 'Enqueue'. 1 post(s) found.
- 2007/08/27 Queue Tutorial In C#
Adding Items to the Queue
To add items to the Queue you use Enqueue method. This method takes an object of any type but to keep things simple lets just give it a string object:
Queue q = new Queue();
q.Enqueue("So");
q.Enqueue("This");
q.Enqueue("Is");
q.Enqueue("How");
q.Enqueue("Queues");
q.Enqueue("Work");
q.Enqueue("So");
q.Enqueue("This");
q.Enqueue("Is");
q.Enqueue("How");
q.Enqueue("Queues");
q.Enqueue("Work");
Viewing a Single Object Without Removing it From the Queue
You can use the Peak method to get the topmost object in the Queue without removing it from the Queue:
Console.WriteLine(q.Peek());
Viewing All the Objects in the Queue Without Removing Them
You can read any of the data in the Queue by using an enumerator:
System.Collections.IEnumerator en = q.GetEnumerator();
while (en.MoveNext())
{
Console.Write(en.Current " ");
}
while (en.MoveNext())
{
Console.Write(en.Current " ");
}
Removing Items from the Queue
To pop an item from the Queue you can use the Dequeue statement. This returns the topmost object of the Queue.
Another posts included in "C#"
| Stack Tutorial In C# (0) | 2007/08/27 |
| HashTable Tutorial In C# (0) | 2007/08/27 |
| Calling Your Main Thread From A Worker Thread In C# (0) | 2007/08/27 |
| Create PDF Files On the Fly In C Sharp (0) | 2007/08/27 |
| How to call Visual C/C++ implemented DLL functions in C# - Simple DLLIm... (0) | 2007/08/26 |
| Send Email Using C# (0) | 2007/08/26 |
| How To Read And Write A Cookie (0) | 2007/08/26 |
| Using C# With Cookies (0) | 2007/08/26 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 04:58
moneyideas
-
Subject different money making ideas
2010/01/29 13:46
moneyideas
-
Subject different money making ideas
2010/01/31 16:44
moneyideas

Prev

Rss Feed