[Solved] Cannot Implicitly Convert int to int[] [closed]


This is because you are trying to assign arrays instead of assigning their members:

idArray     = Int32.Parse(words[0]);

should be

idArray[i]  = Int32.Parse(words[0]);

and so on. Better yet, create EmployeeData class that has individual fields for id, name, dept, and so on, and use it in place of parallel arrays:

class EmployeeData {
    public int Id {get;}
    public string Name {get;}
    public int Dept {get;}
    public double Pay {get;}
    public double Hours {get;}
    public EmployeeData(int id, string name, int dept, double pay, double hours) {
        Id = id;
        Name = name;
        Dept = dept;
        Pay = pay;
        Hours = hours;
    }
}

Now you can make an array or a list of EmployeeData, and create individual employees as you read their info:

var employee = new EmployeeData[numOfEmployees];
// Index i starts from 0, not from 1
for (i = 0; i < numOfEmployees; i++) { 
    words       = fileIn.ReadFields();
    var id = Int32.Parse(words[0]);
    var name = words[1];
    var dept = Int32.Parse(words[2]);
    var pay = Double.Parse(words[3]);
    var hours = Double.Parse(words[4]);
    employee[i] = new EmployeeData(id, name, dept, pay, hours);
}

solved Cannot Implicitly Convert int to int[] [closed]