Given the following code, describe a situation that would make the code ambiguous to the C# compiler:
using static System.Console;
public class AmbiguousMethods
{
static void Main()
{
int iNum = 20;
double dNum = 4.5;
SimpleMethod(iNum, dNum); // calls first version
SimpleMethod(dNum, iNum); // calls second version
SimpleMethod(iNum, iNum); // error! Call is ambiguous.
}
private static void SimpleMethod( int i, double d)
{
WriteLine("Method receives int and double");
}
private static void SimpleMethod( double d, int i)
{
WriteLine("Method receives double and int ");
}
}
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q19: Methods with identical names that have identical
Q20: When you use a(n) _ parameter, the
Q21: What are two options for writing a
Q22: What is programming principle is violated when
Q23: If you assign a default value to
Q25: The rules that determine which method version
Q27: In C#, all data types are _.
Q29: Unnamed method arguments are also known as
Q35: What is the difference between a reference
Q38: What are the four types of mandatory
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents