カテゴリー
Visual Basic

Visual Basicクラスのインスタンスをスタックする

Imports System

Module Program
    Class elem
        Public ope As String
        Public lev As Integer
    End Class
    Sub Main(args As String())

        Dim a As New elem With {.ope = "100", .lev = 0}
        Dim b As New elem With {.ope = "+", .lev = 1}
        Dim elemstack As New Stack
        Dim w As elem
        elemstack.Push(a)
        elemstack.Push(b)

        Do While elemstack.Count > 0
            w = elemstack.Pop
            Console.Write(w.ope + ", ")
            Console.WriteLine(w.lev)
        Loop

        Console.WriteLine("Hello World!")
    End Sub
End Module

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

inserted by FC2 system