using System;
namespace ConsoleApplication1
{
class BaseClass
{
public virtual void show()
{
Console.WriteLine("Base class method is called");
}
}
class DerivedClass : BaseClass
{
public override void show()
{
Console.WriteLine("DerivedClass method is called");
}
}
class MostDerivedClass : DerivedClass
{
public override void show()
{
Console.WriteLine("MostDerivedClass method is called");
}
}
class Program
{
static void Main(string[] args)
{
BaseClass baseObj;
MostDerivedClass obj = new MostDerivedClass();
obj.show();
baseObj = obj;
baseObj.show();
Console.ReadLine();
}
}
}
using System;
namespace ConsoleApplication1
{
abstract class Shape
{
public Shape()
{
Console.WriteLine("Constructor is called from abstract class");
}
public abstract int Area(int length, int breath);
}
class Rectangle : Shape
{
public override int Area(int length, int breath)
{
return length * breath;
}
}
class Program
{
static void Main(string[] args)
{
Rectangle obj = new Rectangle();
Console.WriteLine("Enter the length of rectangle");
int length=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the brath of rectangle");
int breath = Convert.ToInt32(Console.ReadLine());
int area = obj.Area(length, breath);
Console.WriteLine("Area of rectangle ="+area);
Console.ReadLine();
}
}
}
abstract class Shape
{
// ………………
// Your code
public abstract int Length { get; }
public abstract int Breath { get; }
}
class Rectangle : Shape
{
public override int Length
{
get {
// ………………
// Your code
}
}
public override int Breath
{
get {
// ………………
// Your code
}
}
}