C# newbie having problem with arrays in a function

I have created an array of numbers successfully:

double[] wSeries = new double[wFingersPlusNotchesPlusOne];
for (int i = 0; i < wFingersPlusNotchesPlusOne; i++)
{
  wSeries[i] = i * wActualFingerWidth;
}

This would be very useful in my component as a method.
But I cannot get it to work. I have a suspicion that it has something to do with the fact that I don’t specify how many elements my array contain.

double[ ] wSeries(int nr, double fingerWidth)
{
for (int i = 0; i < nr; i++)
{
wSeries[i] = i * fingerWidth;
}
return wSeries;
}

If I try to translate the error-message from swedish it would be something like:

  1. Error (CS0021): You cant use indexing with [ ] in an expression of type methodgroup

that would be in this row:

wSeries[i] = i * fingerWidth;

perhaps replace that line with this
wSeries.SetValue(i*wActualFingerWidth, i);

It seems you are trying to assign a value to the function itself instead of assigning an array (wSeries[i] = …) as if the function itself was the array. (But, thereäs no array at all in the function). A correctly designed function would look something like this instead:

double[ ] GetSeries(int nr, double fingerWidth)
{
    double[] wSeries = new double[nr]; // create a new array
    for (int i = 0; i < nr; i++)
    {
        wSeries[i] = i * fingerWidth;
    }
    return wSeries; // return that new array
}

Hoppas detta hjälper!

// Rolf

This seems reasonable, I’m having trouble changing mindset with functions.
Will give this a try.
Tack för hjälpen!