+ 2
I dont understand what is overloading?
6 Answers
+ 9
Means same name but different argument list đ
+ 7
If I understand this right, method overloading means that you can have more methods with the same name but with (must have) other parameters. If you got a method called "Calc" and it's parameters is (int x, int y) you can have another method called "Calc" but with the parameters (float x, float y).
so whenever you call your method "Calc" and you want to Calculate an int you call the method with Calc (42, 43) and when if you want to calculate a float you call it with Calc (2.4, 5.3)
Does this make sense?
+ 3
If a function has the same signature as another, but differs in its parameters, it is said to be overloaded.
Hence, you can create multiple methods with the same name, which differ in their implementation.
+ 3
You can have 0 or more arguments, as long as they are different from the other function with the same name.
+ 2
That make complete sense, so if you wanted you could overload a method that calculated the perimeter for different shapes
Ex:
public double Perimeter(double a, double b, double c)//triangle{...}
public double Perimeter(double a)//square{...}
public double Perimeter(double w, double h, )//rectangle{...}
As long as the parameter signature is different you can overload a method until you run out shapes (joke).
If you hover your cursor over Console.WriteLine you will see that it has over 18 overloads.
+ 1
overloading the same operator or function for different purposes