Not exactly, you can declare and initialize multiple loop variables, but they need to have the same type. Further, you cant have multiple conditions, but you can combine them via logical operators:

for (int i = 0, j = 1; i < v1.Length && j > 0; i++, j++  )
{
    if (v1[i] == v2[j])
    {
        //do something
    }
}

what also works is to initialize earlier declared variables of different types:

int i; double j;
for ( i = 0, j = 1.5; ... )

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top