So I tried to return my array with a foreach loop… but no results… If someone can help me return an array, it will help me greatly.
Here is the test code of how I tried to do that:
int[] ints = { 1, 2, 3 };
foreach(int i in ints)
{
return ints[i];
}
>Solution :
Like @lee Taylor mentioned. It is weird to do this, but yield is what you want.
int[] ints = { 1, 2, 3 };
foreach(int i in ints)
{
yield return i;
}