What is Polymorphism and why use in C# with example.

Polymorphism

This is the ability of an object to perform in a wide variety of ways. There are two types:
1. Dynamic polymorphism (runtime time). You can obtain this type through executing function overriding.
2. Static polymorphism (compile time). You can achieve static polymorphism through function overloading and operator overloading.
Within OOP, polymorphism can be achieved using many techniques including:
  • Method overloading (defining several methods at the same time)
  • Method overriding (this allows a subclass to override a specific implementation of a method already issued by one of its super-classes)
  • Operator overloading (some or all of the operators are handled has polymorphic functions with different behaviors depending on the types of its arguments)
Share:

No comments:

Post a Comment

Friday, 28 June 2019

What is Polymorphism and why use in C# with example.

Polymorphism

This is the ability of an object to perform in a wide variety of ways. There are two types:
1. Dynamic polymorphism (runtime time). You can obtain this type through executing function overriding.
2. Static polymorphism (compile time). You can achieve static polymorphism through function overloading and operator overloading.
Within OOP, polymorphism can be achieved using many techniques including:
  • Method overloading (defining several methods at the same time)
  • Method overriding (this allows a subclass to override a specific implementation of a method already issued by one of its super-classes)
  • Operator overloading (some or all of the operators are handled has polymorphic functions with different behaviors depending on the types of its arguments)

No comments:

Post a Comment

Popular

Total Pageviews

Archive