I have a class that takes an interface as one of the arguments to it's constructor. Is there a way to create an instance of a specific implementation that I can use as a default value for a parameter?
interface IClassA
{
void AMethod();
}
class ClassA : IClassA
{
void AMethod()
{
// Do stuff
}
}
class Other
{
public Other(IClassA ia = new ClassA())
{
}
}
The compiler error I get for this, and everything else I have tried is "Default parameter value for 'ia' must be a compile-time constant"
this is easily doable in c++ (I'm relatively inexperienced in c#)
How do I make an instance of a class be a compile-time constant?