If I want to override a method 1 of class A and in class b
then how do you declare ?

Answer Posted / ch.venu

Ans:
we can override the parent class method under its child
class only when the parent class declared the method as
virtual

ex:
class Parent
{
public virtual void Test()
}
now thar virtual method of the parent class can be override
the child class using override modifier

ex:

class child:Parent
{
public override void Test()
{
Console.WriteLine("hi this is derived class") ;
}
}

but it is only optional for the child classs to override the
virtual method of its parent class

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you prevent escaping on backslashes in C# with string definitions?

700


What is equal c#?

510


Is it good to use var in c#?

466


List down the fundamental oop concepts?

498


What is the signature of a method?

485






What do u mean by thread safe?

500


What is gac? What are the steps to create an assembly and add it to the gac?

488


What is boxing and unboxing in c#?

472


What is yield keyword?

503


What is the delegate in c#?

494


Is the following code legal?

567


What is yield return in c#?

493


Why do we override in c#?

496


Why do we use static class in c#?

496


Can you inherit multiple abstract classes in c#?

494