I have a class and function
class A
{
A(int i = 0)
{
}
}
void f(A a = new A(10)) // ? default parameter value must be compiler-time constanct
{
}
How to workaround it?
I have a class and function
class A
{
A(int i = 0)
{
}
}
void f(A a = new A(10)) // ? default parameter value must be compiler-time constanct
{
}
How to workaround it?
You would need to do it inside the method and provide a comment that the method accepts null and uses A(10)
as a default value.
void f(A a = null)
{
if(a == null)
a = new A(10);
}