Net-informations.com
SiteMap  | About    

ASP.NET Stack

The Stack class represents a last-in-first-out (LIFO) Stack of Objects. Stack follows the push-pop operations, that is we can Push Items into Stack and Pop it later also it follows the Last In First Out (LIFO) system.

Stack returns the last item first. As elements are added to a Stack, the capacity is automatically increased as required through reallocation.

  Stack.Push(Object) : Add (Push) an item in the Stack data structure.

vb.net
  Dim st As New Stack

st.Push("Sunday")

C#
  Stack st = new Stack();

st.Push("Sunday");

  Object Stack.Pop() : Return the last object in the Stack

vb.net

  st.pop()

C#

  st.pop();

The following ASP.NET program push seven days in a week and bing 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) 2016    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.