ArrayList / Stack / Queue / List 使用方法及出現次序

 

   Default.aspx
 
   <form id="Form1" runat="server">
   <div>
      <asp:Table ID="Table1" runat="server">
 
         <asp:TableRow>
         <asp:TableCell Width="120">
         <asp:Label ID="Label1" runat="server" Text="">
         </asp:Label></asp:TableCell>
         <asp:TableCell Width="120">
         <asp:Label ID="Label2" runat="server" Text="">
         </asp:Label></asp:TableCell>
         <asp:TableCell Width="120">
         <asp:Label ID="Label3" runat="server" Text="">
         </asp:Label></asp:TableCell>
         <asp:TableCell Width="120">
         <asp:Label ID="Label4" runat="server" Text="">
         </asp:Label></asp:TableCell>
         </asp:TableRow>
 
         <asp:TableRow>
         <asp:TableCell Width="120">
         <asp:Label ID="Label5" runat="server" Text="FIFO" Font-Bold="True" />
         </asp:TableCell>
         <asp:TableCell Width="120">
         <asp:Label ID="Label6" runat="server" Text="LIFO" Font-Bold="True" />
         </asp:TableCell>
         <asp:TableCell Width="120">
         <asp:Label ID="Label7" runat="server" Text="FIFO" Font-Bold="True" />
         </asp:TableCell>
         <asp:TableCell Width="120">
         <asp:Label ID="Label8" runat="server" Text="FIFO" Font-Bold="True" />
         </asp:TableCell>
         </asp:TableRow>
 
      </asp:Table>
   </div>
   </form>
 

 

   Default.aspx.vb
 
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Dim A As New ArrayList
      A.Add("1A")
      A.Add("2A")
      A.Add("3A")
      A.Add("4B")
      A.Add("5B")
      A.Add("6B")
      A.Add("7C")
      A.Add("8C")
      A.Add("9C")
 
      Label1.Text = "<B>ArrayList : </B><BR>"
 
      For Each s As String In A
         Label1.Text += s.ToString & "<BR>"
      Next
 
      Dim B As New Stack
      B.Push("1A")
      B.Push("2A")
      B.Push("3A")
      B.Push("4B")
      B.Push("5B")
      B.Push("6B")
      B.Push("7C")
      B.Push("8C")
      B.Push("9C")
 
      Label2.Text = "<B>Stack : </B><BR>"
 
      For Each s As String In B
         Label2.Text += s.ToString & "<BR>"
      Next
 
      Dim C As New Queue
      C.Enqueue("1A")
      C.Enqueue("2A")
      C.Enqueue("3A")
      C.Enqueue("4B")
      C.Enqueue("5B")
      C.Enqueue("6B")
      C.Enqueue("7C")
      C.Enqueue("8C")
      C.Enqueue("9C")
 
      Label3.Text = "<B>Queue : </B><BR>"
 
      For Each s As String In C
         Label3.Text += s.ToString & "<BR>"
      Next
 
      Dim D As New List(Of String)
      D.Add("1A")
      D.Add("2A")
      D.Add("3A")
      D.Add("4B")
      D.Add("5B")
      D.Add("6B")
      D.Add("7C")
      D.Add("8C")
      D.Add("9C")
 
      Label4.Text = "<B>List : </B><BR>"
 
      For Each s As String In D
         Label4.Text += s.ToString & "<BR>"
      Next
 
   End Sub