How Function overloading saves memory.
At runtime, it doesn’t. Overloading is resolved at compile time, so it has no impact on performance.
What is difference between the following two types of functions
definitions,
They are overloaded functions, taking multiple parameters, which IMO would be more readable
which one should be used ?
Overloading would be more readable, (You may also see Member Overloading – MSDN) but If you are using C# 4.0 or higher then you can use optional parameters as well.
Define it like:
public int ADD(int a, int b, int c = 0, int d = 0)
{
//..... your code
return result;
}
Call it like:
ADD(2, 3);
ADD(2, 3, 4);
ADD(2, 3, 4, 5);