I am trying to pass an array of doubles into a mehtod in another class that will some calculations and return another array of doubles.
Here is how I am currently calculating it.
private void btnCalcLGM_Click(object sender, EventArgs e)
{
public double[] myInputArray = {455.0,400.0,300.0,200.0,100.0};
LogisticGrowthDCA prodArray = new LogisticGrowthDCA (myInputArray);
}
And here is the class and method I am trying to call.
public class LogisticGrowthDCA
{
private double defaultK = 500000;
private double defaultA = 50;
private double defaultN = .5;
public double[] myArray;
public LogisticGrowthDCA(double[] myInputArray)
{
for (int i = 0; i< myInputArray.Length; i++)
{
myArray[i] = myInputArray[i]; //do some calculation
return myArray;
}
}
}
It says I am getting errors like: "A field initializer cannot reference the non-static field, method, or property 'DataAccessProject.Form1.myInputArray'"
How do I return an array from my method and why can't I pass an array into the method?