Category >
CSHARP
|| Published on :
Saturday, November 14, 2020 || Views:
703
||
abstract class abstract method
Here Pawan Kumar will explain how to show how we can use abstract class and abstract method
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication18
{
abstract class A
{
public virtual void Show()
{
Console.WriteLine("Show A");
}
public virtual void Fun()
{
Console.WriteLine("Fun A");
}
public abstract void Call();
}
class B : A
{
public override void Show()
{
Console.WriteLine("Show B");
}
public override void Call()
{
Console.WriteLine("Call B");
}
}
class Demo
{
static void Main(string[] args)
{
B b = new B();
Console.WriteLine("----B----");
b.Show();
b.Fun();
b.Call();
A a = b;
Console.WriteLine("----(A=B)----");
a.Show();
a.Fun();
a.Call();
Console.ReadLine();
}
}
}