using System;
public abstract class Animal
{
public abstract string GetName();
abstract public int Speed { get; }
}
using System;
public class Cheetah : Animal
{
public override int Speed
{
get
{
return 100;
}
}
public override string GetName()
{
return "cheetah";
}
}
using System;
public class Turtle : Animal
{
public override int Speed
{
get
{
return 1;
}
}
public override string GetName()
{
return "turtle";
}
}
using System;
class AbstractClasses
{
static void Main()
{
Turtle turtle = new Turtle();
Console.WriteLine("The {0} can go {1} km/h ",
turtle.GetName(), turtle.Speed);
Cheetah cheetah = new Cheetah();
Console.WriteLine("The {0} can go {1} km/h ",
cheetah.GetName(), cheetah.Speed);
System.Collections.Generic.List<int> l;
System.DateTime dt;
}
}
OUTPUT
The turtle can go 1 km/h
The cheetah can go 100 km/h
public abstract class Animal
{
public abstract string GetName();
abstract public int Speed { get; }
}
using System;
public class Cheetah : Animal
{
public override int Speed
{
get
{
return 100;
}
}
public override string GetName()
{
return "cheetah";
}
}
using System;
public class Turtle : Animal
{
public override int Speed
{
get
{
return 1;
}
}
public override string GetName()
{
return "turtle";
}
}
using System;
class AbstractClasses
{
static void Main()
{
Turtle turtle = new Turtle();
Console.WriteLine("The {0} can go {1} km/h ",
turtle.GetName(), turtle.Speed);
Cheetah cheetah = new Cheetah();
Console.WriteLine("The {0} can go {1} km/h ",
cheetah.GetName(), cheetah.Speed);
System.Collections.Generic.List<int> l;
System.DateTime dt;
}
}
OUTPUT
The turtle can go 1 km/h
The cheetah can go 100 km/h