It is possible to define two or more methods within the same class that having the same name, as long as their parameter declarations are different. When this is the case, the methods are said to be overloaded, and the process is referred to as method overloading. Same method name but having different types of signatures in the same scope.
public class AddNumber { public int Add(int x, int y) { return x+y; } public int Add(int x, int y, int z) { return x+y+z; } }
We define a Add method, in two different versions. The first one takes two paramaters, for adding two numbers, while the second version takes three parameters.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Same method name but having different types of signatures in the same scope.
We define a Add method, in two different versions. The first one takes two paramaters, for adding two numbers, while the second version takes three parameters.