I’m writing some custom C# for one of the UD tables.
I’ve been attempting to google the answer for a bit, but am still stumped on the error.
The error: Error: CS1014 - line 573 (5615) - A get or set accessor expected
The line of code that triggers the error:
Type2Calc myCalc = new Type2Calc(this.epiNumericEditorC30, this.epiNumericEditorC31, this.epiNumericEditorC32, this.epiNumericEditorC41, this.epiNumericEditorC42, this.epiNumericEditorC43);
I know that’s a relatively short snippet of code, but figured I would start there.
The google answers note that this error usually occurs when someone is writing a method and forget the () when declaring the method, thus the compiler believes the line to be a property.
However, I’m just trying to create a new instance, and call the constructor on that instance.
What is Type2Calc? Is that a custom class you wrote? We need more context… looks like you are passing TextEditors into a function?
Also do yourself (and everyone else) a favor and rename your controls… epiNumbericEditorC30 doesn’t mean much in 2 years when you get back in the code…
How do you go about adding code tags in your post?
Sorry, I’ve perused a bit here, but never posted.
Yes, it is a custom class that I wrote (class code below)
The class is setup to take the values from 6 numeric fields, and using those fields as points, calculate the linear regression line of those points.
Well noted on naming the epi fields. I’m the sole developer here, so I hadn’t seen a need up until now, but I will try to change that going forwards. Open to other suggestions as well on the code as I know it’s rough.
class Type2Calc
{
//internals
//the next 5 are sums
private decimal _x;
private decimal _y;
private decimal _x2;
private decimal _y2;
private decimal _xy;
private decimal _n;
private decimal _a;
private decimal _b;
private decimal _r;
private decimal _r2;
//outputs
//put some epiNumeric fields in here
//getters
public decimal N
{
get{return _n;}
set{_n = value;}
}
public decimal A
{
get{return _a;}
set{_a = value;}
}
public decimal B
{
get{return _b;}
set{_b = value;}
}
public decimal R
{
get{return _r;}
set{_r = value;}
}
public decimal R2
{
get{return _r2;}
set{_r2 = value;}
}
//constructor //does most of the work
public Type2Calc(MyPoint[] samples)
{
for (int i = 0; i < samples.Length; i++)
{
this._x += samples[i].X;
this._y += samples[i].Y;
this._x2 += samples[i].X * samples[i].X; //note that decimals don't allow the power function
this._x2 += samples[i].Y * samples[i].Y;
this._xy += samples[i].X * samples[i].Y;
this._n++;
}
FinalCalcs();
}
//constructor //simplified inputs to values
public Type2Calc(EpiNumericEditor x1, EpiNumericEditor y1, EpiNumericEditor x2, EpiNumericEditor y2, EpiNumericEditor x3, EpiNumericEditor y3)
{
this._x = (decimal)x1.Value + (decimal)x2.Value + (decimal)x3.Value;
this._y = (decimal)y1.Value + (decimal)y2.Value + (decimal)y3.Value;
this._x2 = (decimal)x1.Value * (decimal)x1.Value + (decimal)x2.Value * (decimal)x2.Value + (decimal)x3.Value * (decimal)x3.Value;
this._y2 = (decimal)y1.Value * (decimal)y1.Value + (decimal)y2.Value * (decimal)y2.Value + (decimal)y3.Value * (decimal)y3.Value;
this._xy = (decimal)x1.Value * (decimal)y1.Value + (decimal)x2.Value * (decimal)y2.Value + (decimal)x3.Value * (decimal)y3.Value;
this._n = 3; //hard setting as this constructor forces three points
FinalCalcs();
}
private void FinalCalcs()
{
//final calcs
_a = (_y * _x2 - _x * _xy) / (_n * _x2 - _x * _x);
_b = (_n * _xy - _x * _y) / (_n * _x2 - _x * _x);
_r = (decimal)Math.Sqrt((double)((_n * _xy - _x * _y) / ((_n * _x2 - _x * _x) * (_n * _y2 - _y * _y)))); //decimals weren't meant to be manipulated by power functions
_r2 = _r * _r;
}
public decimal TestConcentration(decimal titrant)
{
return (titrant - _a) / _b;
}
}
can you share more of your code? (the Epicor code) that is throwing the error I dont see the correlation from that error to the Message you are receiving.