Can we have the method in drived class with the same name
which is there in base class?
Answer Posted / satya
In C#, derived classes can contain methods with the same
name as base class methods.
*
The base class method must be defined virtual.
*
If the method in the derived class is not preceded by
new or override keywords, the compiler will issue a warning
and the method will behave as if the new keyword were present.
*
If the method in the derived class is preceded with
the new keyword, the method is defined as being independent
of the method in the base class.
*
If the method in the derived class is preceded with
the override keyword, objects of the derived class will call
that method instead of the base class method.
*
The base class method can be called from within the
derived class using the base keyword.
*
The override, virtual, and new keywords can also be
applied to properties, indexers, and events.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is difference between string and stringbuffer in c#?
How do you mark a method obsolete?
Can a loop recorder detect a heart attack?
What is the benefit of interface in c#?
How do I calculate relative time?
Why would you use untrusted verification?
Why do we use dictionary in c#?
What is fcl in c#?
Can you pass value types by reference to a method?
What is console write in c#?
What is difference between array and collection in c#?
Explain the term inheritance in C#.
How to open a new form on button click in Windows forms?
What is Private Constructor? and it’s use? Can you create instance of a class which has Private Constructor?
Which of these string definitions will prevent escaping on backslashes in c#?