Can you allow a class to be inherited but prevent a method f

Can you allow a class to be inherited, but prevent a method from being overridden in C#?

Solution

yes,I can allow a class to be inherited in the following cases

I can expalin with th following example by writing small code

Example:

class A
{
   protected virtual void show()
   {
       //Statements
   }
}

class B : A
{
   sealed protected override void shoe()
   {
       //Statements
   }
}

Can you allow a class to be inherited, but prevent a method from being overridden in C#?Solutionyes,I can allow a class to be inherited in the following cases I

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site