建立public class test
{
public test()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}继承public class test2:test
{
public test2()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}引用
test aa=new test();
....test2 bb=new test2()
....
{
public test()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}继承public class test2:test
{
public test2()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}引用
test aa=new test();
....test2 bb=new test2()
....
{
public A(){};
public Test(){};
}
class B:A
{
pubic B(){};
public Test();//overload the function Test.
}
{
public a()
{
}protected test()
{
}
}class b:public a
{
public b()
{
}
}
{
public A(){};
public Test(){};
}
class B:A
{
pubic B(){};
public Test();//overload the function Test.
}
test 函数应该标名为virtual才好
using System;namespace MySpace { public class myClass : MyParent { int x; public myClass() { x = 4; }
public void Add(int x) { this.x += x; }
override public int GetNum() { return x; }
}
}带 Main 方法的类定义:
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();
}
}
{
string strDBConnect;
int nDBTimeOut;
ParentClass()
{
}}
{
public: MyClassFather(){...}
virtual ~MyClassFather(){...}
private:
}
class MyClassSon:public(publish private) MyClassFather
{
......}
[email protected]