We have seen how Method Hiding & Method Overriding works. It is time know the main difference between them. This will give you the idea when and where to use them. Method Hiding: In method hiding, if both derived class and base class has a same method name with same signature, then we make use
What is Method Overriding? In method hiding in C#.Net, we have seen how to use new keyword in derived class method to hide the base class method. Also, we know that derived class object will always call to its own method in case of method hiding. But if we create a base class reference variable
As per inheritance in C#, derived class have access to all the code available in base class, which means all the public methods available in the base class are accessible through derived class object. But in some cases, derived class contains a method which is similar by name and signature to the method available in
Before we start digging into the inheritance topic, you must need to know there are 4 pillars to object oriented programming. Inheritance Encapsulation Abstraction Polymorphism However, in this session, we will discuss only inheritance. Lets take a very small example to start this concept. Suppose you have to create a report about 10 students. Every
All fields, methods, constructors, properties, events, and indexers are known as Class members. There are 2 type of members, Static and Non-Static. Static member contains Static keyword in front of them. We can have static fields, static methods, static constructors etc. If value of a member is not changing on creation of every new object,