I am pretty new to lambda expressions and am trying to write a simple program here to understand the use of Func<> and can't understand why I cannot loop through an input array using indexing?
class Program
{
static void Main(string[] args)
{
int[] array = new int[4];
array[0] = -1; array[1] = 2; array[2] = 3; array[3] = 8;
Func<Array, int> DoSomething = inputarray =>
{
for (int i = 0; i < inputarray.Length; i++)
{
if (inputarray[i] > inputarray[i + 1])
{
//;
}
}
return 1;
};
}
}
This gives an error saying
cannot apply indexing with [] to an expression of type Array
How do I resolve this? Basically, how would I loop through my input array?
Arrayrefers toSystem.Arraywhich is not exactly an array.