Is it possible to simplify the codes below by using while loop?

            Match firstMatch1 = matches1[0];
            Match firstMatch2 = matches1[1];
            Match firstMatch3 = matches1[2];
            Match firstMatch4 = matches1[3];
            Match firstMatch5 = matches1[4];
            Match firstMatch6 = matches1[5];
            Match firstMatch7 = matches1[6];
            Match firstMatch8 = matches1[7];
            Match firstMatch9 = matches1[8];
            Match firstMatch10 = matches1[9];`

E.g.

int i =0
while (i<54)
{
Match firstMatch1 = matches1[i]
...
i++;
}

Maybe something like this?

public class Match
    {
        public int match=0;
    }

    List<Match> M = new List<Match>(54);
            int i = 0;
            while (i < 54)
            {
                M[i].match = i;
                //...
                i++;
            }

Sorry but I got a bit confused here.
Do you mind explaining a little?

I'll give it a try:
Since you did not tell me what Match was I made my own Match class.

public class Match
{
    public int match = 0;
}

Instead of a List, I will use an array now:

Match[] M = new Match[54];
int i = 0;
while (i < 54)
{
    M[i].match = i;
    //...
    i++;
}

In the while loop I set the match field of my Match class to the value of the loop counter.
You always have to use some sort of array or list to loop through with a while statemnent.
You cannot loop through variables with a digit in their name like Var1,Var2,Var3...
That's the reason arrays where "invented"!

That's very helpful! Thumbsup and thanks !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.