I am trying to create an array of 20 candidates from my Candidate class. So far, this is what I have:
Candidate candidate0 = new Candidate();
Candidate candidate1 = new Candidate();
Candidate candidate2 = new Candidate();
Candidate candidate3 = new Candidate();
...
Candidate candidate19 = new Candidate();
Candidate[] candidates = new Candidate[20];
candidates[0] = candidate0;
candidates[1] = candidate1;
candidates[2] = candidate2;
candidates[3] = candidate3;
...
candidates[19] = candidate19;
I know this is not the correct or 'best' way to do this. What would be the best way?
for(int i=0;i<candidates.Length;i++){candidates[i] = new Candidate();}