I played with additional parameters and was executed according to the following scenario.
If I have a method in my class where all parameters are optional, I can write the following code:
public class Test
{
public int A(int foo = 7, int bar = 6)
{
return foo*bar;
}
}
public class TestRunner
{
public void B()
{
Test test = new Test();
Console.WriteLine(test.A());
}
}
If I then create an interface, for example:
public interface IAInterface
{
int A();
}
If I create a Test class that implements this interface, then it will not compile, because it says that the A () interface element from IAInterface is not implemented. Why is the implementation of the interface not allowed as a method with all the optional parameters?
source
share