15/09/2016
C #: Inheritance Example ; Single.........
namespace inheritance
{
class Program: value //main class
{
static void Main(string[] args)
{
work w = new work();
w.getValue();
w.displayValue();
w.findArea();
}
}
public class value //class name 'value'
{
public int l, b;
public void getValue()
{
Console.WriteLine("enter value of length and breadth");
l = Convert.ToInt16(Console.ReadLine());
b = Convert.ToInt16(Console.ReadLine());
}
public void displayValue()
{
Console.WriteLine("Value of length={0} ",+l+" Value of Breadth="+b);
}
}
class work: value //class name 'work' ; 'value' class
is inherited in this class
{
public void findArea()
{
int a;
a = l * b;
Console.WriteLine("Area for given Length and Breadth is={0}", a);
}
}
}