I have this as Main
int[] M ={ 10, 2, 30, 4, 50, 6, 7, 80 };
MyMath.Reverse(M);
for (int i = 0; i < M.Length; i++)
Console.WriteLine(M[i].ToString() + ", ");
After I created the class MyMath I made the Reverse method
public int Reverse(Array M)
{
int len = M.Length;
for (int i = 0; i < len / 2; i++)
{
int temp = M[i]; M[i] = M[len - i - 1]; M[len - i - 1] = temp;
}
}
but I'm sure it's wrong because it's not working :-) so do you have a different code to write in the reverse method?
note: I don't want to use the built in Reverse in the Array class
yes guys when i used the built in reverse method i got this error
Process is terminated due to StackOverflowException.
thats after i wrote the method as
public static int Reverse(Array M)
{
return Reverse(M);
}
So then I tried to create my own reverse method and there i got stuck