I'm getting a compilation error "not all code paths return a value" on the following code, How come?!
public class SomeEntity
{
public int m_i;
public SomeEntity(int i)
{
m_i = i;
}
public override string ToString()
{
return m_i.ToString();
}
public static int someFunction(int i) { return i + 100; }
public static IEnumerable GetEntities()
{
int [] arr = {1,2,3};
foreach (int i in arr)
{
// for (int i = 0; i < someArray.Count();i++)
// yield return new SomeEntity(someFunction(i));
// *** Equivalent linq function ***
return Enumerable.Range(0, 7).Select(a => new SomeEntity(someFunction(a)));
}
}
}
I can't seem to figure this out..... I tried converting the outer foreach loop to a linq expression
public static IEnumerable GetEntities()
{
int [] arr = {1,2,3};
return arr.Select(Xenv =>
Enumerable.Range(0, 7).Select(a => new SomeEntity(someFunction(a)))
);
}
but then I just got an error :/
yieldkeyword, right?int ianyway