I have a class Employee:
public class Employee
{
public Employee()
{
}
public int Id { get; set; }
public string Name { get; set; }
public Employee Manager { get; set; }
}
and a csv file which contain all the employees, 1st part of a line is the Id, 2nd part is the name, and the 3rd part is the Id of the manager, if it's a empty then the employee doesn't have a manager:
2;John;1
1;James;
3;Linda;1
I created a class CsvReader, in this class I have a method GetEmployees, the problem is that I cannot assign a value to the property Manager!
...
var lines = File.ReadAllLines(this.FilePath);
foreach (var line in lines)
{
var parts = line.Split(';');
var emp = new Employee();
emp.Id = int.parse(parts[0]);
emp.Name = parts[1];
emp.Manager = ????
}
return employees;
}
I hope that the problem is clear