A generic Stack class (VB) : Generics « Collections « ASP.NET Tutorial






<%@ Page Language="VB" %>
    
<script runat="server">
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim myStack As New System.Collections.Generic.Stack(Of String)
        myStack.Push("A")
        myStack.Push("B")
        myStack.Push("C")
    
        Dim myArray As Array
        myArray = myStack.ToArray()
    
        For Each item As String In myArray
           Label1.Text += item & "<br />"
        Next
     End Sub
</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>








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#)