While trying to make a regular constructor to constructor call in the same class :
public Equation(OrdinaryEquations equation,
double xTranslation,
double yTranslation,
double rotationAngle)
: this( (equation == OrdinaryEquations.SecondOrder) ? new EquationFunction(SecondOrderEquation) : new EquationFunction(ThirdOrderEquation),
xTranslation, yTranslation, rotationAngle){}
OrdinaryEquations is enumeration
EquationFunction is a delegate
I get this error :
” An object reference is required for the non-static field, method, or property”
foreach : ” new EquationFunction(SecondOrderEquation)” and “new EquationFunction(ThirdOrderEquation)”
which sounds like when I try to access object data from static method
the other constructor sig. :
public Equation(EquationFunction equation, double xTranslation, double yTranslation, double rotationAngle){}
Is there something I’m missing here ? I can’t figure out what to do !!
P.S I removed the conditional operator and made it a normal object initialization but gave the same error
I assume “SecondOrderEquation” is a method name in your class “Equation”.
The usage of “SecondOrderEquation” refers to this.SecondOrderEquation which needs a instance of type “Equation” to be a context.
To fix it, you can try to make “SecondOrderEquation” and “ThirdOrderEquation” to be static methods.