Mega Code Archive

 
Categories / ASP.Net Tutorial / Collections
 

A generic Stack class (C#)

<%@ Page Language="C#" %>      <script runat="server">     void Page_Load(object sender, EventArgs e)     {         Stack<string> myStack = new Stack<string>();         myStack.Push("A");         myStack.Push("B");         myStack.Push("C");              Array myArray;         myArray = myStack.ToArray();              foreach (string item in myArray)         {              Label1.Text += item + "<br />";         }     } </script>        <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>Untitled Page</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:Label runat="server" ID="Label1"></asp:Label>     </div>     </form> </body> </html>