扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者: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 |
濡傛灉鎮ㄩ潪甯歌揩鍒囩殑鎯充簡瑙T棰嗗煙鏈€鏂颁骇鍝佷笌鎶€鏈俊鎭紝閭d箞璁㈤槄鑷抽《缃戞妧鏈偖浠跺皢鏄偍鐨勬渶浣抽€斿緞涔嬩竴銆�