扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:Crystal编译 来源:yesky 2007年11月11日
关键字:
Listing 1:Employee类 Class Employee End Class |
Listing 2: Class Employee Public Sub Work () ' Do something here End Sub End Class |
Class Employee Dim salary As Decimal = 40000 Dim yearlyBonus As Decimal = 4000 Public Sub PrintSalary() ' print the salary to the Console System.Console.Write(salary) End Sub End Class |
Listing 4: 对象初始化 Class Employee Dim salary As Decimal = 40000 Dim yearlyBonus As Decimal = 4000 Public Sub PrintSalary() ' print the salary to the Console System.Console.Write(salary) End Sub End Class Module Module1 Public Sub Main() Dim anEmployee As Employee anEmployee = New Employee() anEmployee.PrintSalary() End Sub End Module |
Dim anEmployee As Employee |
anEmployee = New Employee() |
anEmployee.PrintSalary() |
Listing 5: Moving the Main sub to the class itself Class Employee Dim salary As Decimal = 40000 Dim yearlyBonus As Decimal = 4000 Public Sub PrintSalary() ' print the salary to the Console System.Console.Write(salary) End Sub Public Shared Sub Main() Dim employee As Employee employee = New Employee() employee.PrintSalary() End Sub End Class |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。