A generic Stack class using integers (C#) : Generics « Collections « ASP.NET Tutorial






<%@ Page Language="VB" %>
    
<script runat="server">
    void Page_Load(object sender, EventArgs e)
    {
        Stack<int> myStack = new Stack<int>();
        myStack.Push(5);
        myStack.Push(3);
        myStack.Push(10);
    
        Array myArray;
        myArray = myStack.ToArray();
    
        int x = 0;
        foreach (int item in myArray)
        {
            x += item;
        }
    
        Label1.Text = x.ToString();
    }
</script>








7.4.Generics
7.4.1.Generic collections
7.4.2.Creating a list of Person objects using generics (C#)
7.4.3.Creating a list of Person objects using generics (VB)
7.4.4.A generic Stack class (VB)
7.4.5.A generic Stack class (C#)
7.4.6.A generic Stack class using integers (VB)
7.4.7.A generic Stack class using integers (C#)