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 do you use c# for?
How to get the sum of last 3 items in a list using lambda expressions?
Is arraylist type safe in c#?
Is multilevel inheritance possible in c#?
Define assert() method? How does it work?
What are access modifiers in c#?
What are the 2 broad classifications of fields in c#?
Distinguish between continue and break statement?
What is the use of partial methods?
Why delegates are required?
Is c# lazy thread safe?
What are the features of c#?
Which is faster hashtable or dictionary?
How do I run managed code in a process?
Define constructor in c#.