// Someone could explain, Why this code, do not output yet exactly the same List as the series component?
private void RunScript(double Start, double Step, int Count, ref object Series)
{
List<double> numbers = new List<double>();
// S = Start
// N = Step
// C = Count
for (double i = Start; i < Start + (Step * Count); i += Step){
numbers.Add(i);
}
Series = numbers;
}
I would recommend not using floating point maths to determine loop iterations. Whether or not your supposedly final i value is going to be 30.00000000002 or 29.9999999998 might as well be a matter of chance.
Use integers to count loop iterations and compute the floating point value afresh inside each iteration.
Yeah don’t use recursion if you can help it. C# is stack recursive, not tail-recursive so there’s only so many steps you can take before you get a stack overflow exception.
double[] numbers = new double[Count];
for (int i = 0; i < Count; i++)
numbers[i] = Start + i * Step;