Skip to main content
added 35 characters in body
Source Link

this works like a charm, no need for linq or other extensions

int[] anArray = { 1, 5, 2, 7 };
int n, i, mx;
int j = 0;

mx = anArray[0];


for (i = 1; i < anArray.Length; i++)
{
    if (anArray[i] > mx)
    {
        mx = anArray[i];
        j = i;
    }
}

Console.Write("The largest value is: {0}, of index: {1}", mx, j);

this works like a charm

int[] anArray = { 1, 5, 2, 7 };
int n, i, mx;
int j = 0;

mx = anArray[0];


for (i = 1; i < anArray.Length; i++)
{
    if (anArray[i] > mx)
    {
        mx = anArray[i];
        j = i;
    }
}

Console.Write("The largest value is: {0}, of index: {1}", mx, j);

this works like a charm, no need for linq or other extensions

int[] anArray = { 1, 5, 2, 7 };
int i, mx;
int j = 0;

mx = anArray[0];


for (i = 1; i < anArray.Length; i++)
{
    if (anArray[i] > mx)
    {
        mx = anArray[i];
        j = i;
    }
}

Console.Write("The largest value is: {0}, of index: {1}", mx, j);
Source Link

this works like a charm

int[] anArray = { 1, 5, 2, 7 };
int n, i, mx;
int j = 0;

mx = anArray[0];


for (i = 1; i < anArray.Length; i++)
{
    if (anArray[i] > mx)
    {
        mx = anArray[i];
        j = i;
    }
}

Console.Write("The largest value is: {0}, of index: {1}", mx, j);