How to create a method with a constructor?

FranK Duc 121 Reputation points
2021-12-13T13:41:41.377+00:00

Hello,

I am trying to for loop a list from another class.

I have this class

protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{

for(int z = 0; z < 40; z++)
{
fibo2 = (listm[z] - lowPrice0) / (Ncma - lowPrice0);
}
}

I want to create some method from outside the class to reproduce the for loop.

Something like:

private double RunCalculation(int z)
{
for(int z = 0; z < 40; z++)
{
return z;
}
}

So it can produce this instead: fibo2 = (listm[RunCalculation] - lowPrice0) / (Ncma - lowPrice0);
The goal is to remove the brackets of the for loop in the first class because the code is very long and it encompasses to much code.

Is this feasible ?

Thank you

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,978 questions
{count} votes