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
What is Implementation inheritance and interface inheritance?
What is c# console application?
Explain a MSIL ? Why is it appreciated by all developers?
Explain the difference between abstract class and interface in .net?
How do you specify a custom attribute for the entire assembly?
How long will it take to learn c#?
When should we use sealed class in c#?
What is the use of static members with example using c#.net.
What does an indexer do?
What are strings in c#?
Why do we need indexers in c#?
What is difference between sleep () and wait ()?
What is the difference between class and namespace?
What is .net console?
What is static variable in c#?