using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class inheritance 1
{
//virtual Virtual functions , It's easy to subclass it that way
public virtual double Area(double a)
{
return a * 2;
}
}
class Test : inheritance 1
{
// Overrides the parent class Area, Of course, you can also call the parent class Area methods
public override double Area(double b)
{
// The keyword base.Area() The parent class is called Area methods
return base.Area(b) * 0.9;
}
}
class Result
{
static void Main()
{
Test TT = new Test();
Console.WriteLine(TT.Area(10));
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Class4
{
// statement 2 constructors
public Class4()
{
Console.WriteLine("Class4");
}
int i;
public Class4(int a)
{
i=a;
Console.WriteLine("Class:{0}", i);
}
public void SS()
{
Console.WriteLine("BOSS");
}
}
class Test:Class4
{
// Call the parent class ( No parameters ) The constructor
public Test()
: base()
{
}
// Call the parent class ( A parameter ) The constructor
public Test(int a)
: base(a)
{
base.SS();
}
}
class TT
{
static void Main()
{
Test T = new Test();
Test T1 = new Test(10);
}
}
}