WRITE A PROGRAM to avoid inheritance of
particular method.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication20
{
class A
{
public virtual void Show()
{
Console.WriteLine("Show A");
}
}
class B
: A
{
public sealed override void Show()
{
Console.WriteLine("Show B");
}
}
class C
: B
{
public override void Show() //
Error
:sealed method in B cant be override
{
Console.WriteLine("Show B");
}
}
class
Demo
{
static void Main(string[] args)
{
B b = new B();
A a = b;
a.Show();
Console.ReadLine();
}
}
}