asp+语法介绍(一)(4) public void Add(int x) { this.x += x; } public int GetNum() { return x; } } } VB: Imports System Namespace MySpace Public Class Foo : Inherits Bar Dim x As Integer Public Sub New() MyBase.New() x = 4 End Sub Public Sub Add(x As Integer) Me.x = Me.x + x End Sub Public Function GetNum() As Integer Return x End Function End Class End Namespace 16 声明类的主函数 C#: using System; public class ConsoleCS { public ConsoleCS() { Console.WriteLine("Object Created"); } public static void Main (String[] args) { Console.WriteLine("Hello World"); ConsoleCS ccs = new ConsoleCS(); } } VB Imports System Public Class ConsoleVB Public Sub New() MyBase.New() Console.WriteLine("Object Created") End Sub Public Shared Sub Main() Console.WriteLine("Hello World") Dim cvb As ConsoleVB cvb = New ConsoleVB() End Sub End Class 17 标准模块 C# using System; public class Module {