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


Please Help Members By Posting Answers For Below Questions

What is xml comments in c#?

689


Are structs value types or reference types?

759


In which format you can pass the value in the sleep function?

736


What are cshtml files?

658


Differentiate between sqlclient oledb and providers?

714


What is serialization and deserialization in c# with example?

656


How do you specify a custom attribute for the entire assembly?

660


Why c# is type safe?

703


Is c# different than c++?

683


Can extension methods access private members?

671


Explain About ADO and its objects

764


Describe the overview of clr integration.

671


What is entity framework c#?

624


Is c# 8 released?

669


What is the purpose of a constructor in c#?

653