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
How can you reference current thread of the method ?
What is dataset and dataadapter in c#?
What is difference between dll and exe in c#?
What is dataview c#?
What are Namespaces?
What is different about switch statements in c#?
What is list array in c#?
Explain the steps to create satellite assembly?
What is the usage of Enumeration in C# Programming and is it good to use or not ?
Is list a collection c#?
What can be done with c#?
What is the difference between static and constant variables?
How do you create user defined data types in c#?
What are delegates and why are they required?
What is difference between list and dictionary in c#?