Method Overloading is a feature that allows creation of multiple methods with the same name but each method should differ from another in the context of input and output of the function. No two methods must have the same type parameters. Either they must differ in the number of parameters or in the type of the parameters.
You can also refer to Method Overloading as a compile-time polymorphism since the calling method knows the address of the called method and the method addresses are resolved at compile time. This is also called as Early Binding.
Example:
- [ServiceContract]
- public interface ICalenderService
- {
- [OperationContract(Name = ”GetScheduledEventsByDate”)]
- ScheduledEvent[] GetScheduledEvents(DateTime date);
- [OpeartionContract(Name = ”GetScheduledEventsByDateRange”)]
- ScheduledEvent[] GetScheduledEvents(DateTime start, DateTime end);
- }