Hello , I am learning c# currently .. I was looking for some sources on internet to learn and so I found this code , I understand everything but this part :
public Calculator(double l, double w) : base(l, w) { }
/// base.Display();
What is base ? Just explain me how and why is base created .. I really don't understand !
Here's my code :
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InheritanceApplication
{
class Rectangle
{
protected double length;
protected double width;
public Rectangle(double l, double w)
{
length = l;
width = w;
}
public double GetArea()
{
return width * length;
}
public void Display()
{
Console.WriteLine("Length: {0}", length);
Console.WriteLine("Width: {0}", width);
Console.WriteLine("Area: {0}", GetArea());
}
}
class Calculator : Rectangle
{
public Calculator(double l, double w) : base(l, w) { }
public double GetCost()
{
double cost;
cost = GetArea() *50;
return cost;
}
public void Display()
{
base.Display();
Console.WriteLine("Cost: {0}", GetCost());
}
}
class Execute
{
static void Main()
{
Calculator kenny = new Calculator(2.5, 3.5);
kenny.Display();
}
}
}
Thank you vm for your time