Polymorphism

Definition & Meaning

Last updated 23 month ago

What is Polymorphism in C Sharp?

PolyMorphism, in C#, is the potential of Objects of different sorts to provide a completely unique Interface for extraordinary Implementations of Methods. It is generally used in the Context of overdue binding, in which the behavior of an item to reply to a call to its approach individuals is decided based totally on object kind at Run Time. Polymorphism allows redefining methods in derived training.

Polymorphism bureaucracy one of the essential principles of item-orientated Programming, along with Encapsulation and Inheritance.

What Does Polymorphism Mean?

Method Overloading, Constructor overloading and Operator Overloading are taken into consideration bring together-time (also known as Static or ad-hoc) polymorphism, or Early Binding. Method Overriding, which entails inheritance and virtual Functions, is known as runtime (additionally referred to as dynamic, inclusion, or Subtyping) polymorphism, or Late Binding. In the case of assemble-time polymorphism, identification of the overloaded approach to be carried out is achieved at collect time. However, in runtime polymorphism, the type of the item from which the overridden technique can be known as is identified at run time.

In C#, polymorphism is applied through inheritance and using the key-word "virtual". Derived instructions inherit the base magNiFicence participants, except Constructors, primarily based on their Accessibility Ranges. Hence, the Compiler generates the Code to test and pick out the ideal object type (this is pointed to via the Reference Type) at runtime and the correct technique to be referred to as.

An example of polymorphism is an employee Base Class, which incorporates all the basic details about personnel. Classes inclusive of clerk and manager could inherit from the employee base class with unique implementations (via overriding Digital methods) anyplace essential within the derived instructions.

Share Polymorphism article on social networks

Your Score to Polymorphism article

Score: 5 out of 5 (1 voters)

Be the first to comment on the Polymorphism

7593- V4

tech-term.com© 2023 All rights reserved