I try to fill the an array with the result which get from below function.
The function is:
private int Sum(int i)
{
for (int j = 1; j <= i + 1; j++)
{
if (i % j == 0)
{
s += j;
}
}
return s;
}
I create an array and then try to use SetValue() or evaluate directly to fill the array with the results.
for example, Array[1]=Sum(1);
However, none of them works.
=====================================================
[Update for more details]
I need use an array with large amount.
int[] arr = new int[10000]
I try use below codes
foreach (int i in arr)
{
arr.SetValue(Sum(i),i);
}
And
for(int i = 0; i<10001; i++)
{
arr[i]=Sum(i);
}
None of them works.
======================================================
Is there a way to fill the array with functions?
Sorry for my poor English. :(
Thanks
SuT