July 2019
Intermediate to advanced
410 pages
10h 32m
English
Static or early binding polymorphism happens at compile time and it primarily consists of method overloading, where a class has multiple methods with the same name but with different parameters. This is often useful to convey a meaning behind the method or to simplify the code. For example, in a calculator, it is more readable to have multiple methods for adding different types of number rather than having a different method name for each scenario; let's compare the following code:
int Add(int a, int b) => a + b;float Add(float a, float b) => a + b;decimal Add(decimal a, decimal b) => a + b;
In the following, the code is shown again with the same functionality, but without overloading the Add() method:
int AddTwoIntegers(int ...
Read now
Unlock full access