Net-informations.com
SiteMap  | About    

ASP.NET Queue

The Queue works like FIFO system , a first-in, first-out collection of Objects. We can Enqueue (add) items in Queue and we can Dequeue (remove from Queue ) or we can Peek (that is we will get the reference of first item ) item from Queue. Queue accepts null reference as a valid value and allows duplicate elements

  Queue.Enqueue(Object) : Add an Item in the Queue

vb.net
  Dim qu As New Queue

qu.Enqueue("Sunday")

C#
  Queue qu = new Queue();

qu.Enqueue("Sunday");

  Object Queue.Dequeue() : Remove the oldest item from the Queue

vb.net

  qu.Dequeue()

C#

  qu.Dequeue();

The following ASP.NET program add seven days in week to a Queue and bind it to a ListBox control.

Default.aspx

  

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
		<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
		<br />
		<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox><br />
	</div>
	</form>
</body>
</html>


Click the following links to see full source code

C# Source Code
VB.NET Source Code
Default.aspx.cs
Default.aspx.vb






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.