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
How can you prevent escaping on backslashes in C# with string definitions?
What is equal c#?
Is it good to use var in c#?
List down the fundamental oop concepts?
What is the signature of a method?
What do u mean by thread safe?
What is gac? What are the steps to create an assembly and add it to the gac?
What is boxing and unboxing in c#?
What is yield keyword?
What is the delegate in c#?
Is the following code legal?
What is yield return in c#?
Why do we override in c#?
Why do we use static class in c#?
Can you inherit multiple abstract classes in c#?