Explanation of Solution
Method overloading:
- Method overloading means that a class contains multiple methods with the same name, but different types of parameters.
- It is one of the features of polymorphism in object oriented
programming . - When differentiating overloaded method, the compiler does not consider the return type.
- When two methods are declared with the same signature and different return types, then it throws a compile-time error.
- Method overloading takes place by changing:
- Number of parameters in two methods.
- Order of parameters of methods.
- Data types of parameters of methods.
Example:
//Include libraries
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
//Define namespace
namespace ParameterizedConstructorExample
{
//Define a class
class Sample
{
// Method to add two integer values
public int Add(int a, int b)
{
//Assign value
int sum = a + b;
//Display value
return sum;
}
//Method to add three integer values
public int Add(int a, int b, int c)
{
//Assign value
int sum = a + b + c;
//Display value
return sum;
}
// Main Method
�...
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Pearson eText for Starting out with Visual C# -- Instant Access (Pearson+)
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education