The problem is with the definitions of your constructors in the Program
class
Because the argument to the second is optional, then both are candidates when calling using New Program()
. This creates the ambiguity.
Instead, define your constructors using this sort of pattern:
public Program()
: this(10)
{
}
public Program(int num)
{
n = num;
}
or just the single constructor:
public Program(int num = 10)
{
n = num;
}
(Personally I prefer the first of these).