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
Can we inherit sealed class in c#?
1. Describe page life cycle?
Explain about CTS?
What is the difference between an application domain and a process?
Can we declare class as protected?
Why do we use static methods in c#?
Perfect Example Of While And Do-While Loop In C#.Net ?
What is difference between list and dictionary in c#?
What are static and dynamic variables?
What is difference between dictionary and hashtable?
What is the differences between datagrid, datalist and repeater in .net?
What is Wrapper class in dot net?
What is distribute by in hive?
Can a constructor be private in c#?
What is strongly typed in c#?