C#不一致的可访问性错误

我无法修复C#中面向对象程序中的错误。 该计划有9个class级和一个class级。 错误是可访问性不一致:参数类型’Employee.Employee’比方法’Employee.EmployeeInput.CollectEmployeeInfo(Employee.Employee)’更难以访问

public static void CollectEmployeeInfo(Employee theEmployee) { theEmployee.Firstname = InputUtilities.getStringInputValue("First Name"); theEmployee.Lastname = InputUtilities.getStringInputValue("Last name"); theEmployee.Gender = InputUtilities.getCharInputValue("Gender"); theEmployee.Dependents = InputUtilities.getIntegerInputValue("# Dependents"); } 

CollectEmployeeInfo是显示错误的内容,我不确定必须对其他类做什么来修复错误。 任何帮助将不胜感激

 class Employee { public const double MIN_SALARY = 20000; public const double MAX_SALARY = 100000; public const int MIN_DEPENDENTS = 0; public const int MAX_DEPENDENTS = 10; public const string DEFAULT_NAME = "not given"; public const char DEFAULT_GENDER = 'U'; public const string DEFAULT_TYPE = "Generic Employee"; protected string firstName; protected string lastName; protected double annualSalary; protected char gender; protected int dependents; protected static int numEmployees = 0; protected Benefits employeeBenefits; protected string employeeType; public Employee() { firstName = DEFAULT_NAME; lastName = DEFAULT_NAME; annualSalary = MIN_SALARY; dependents = MIN_DEPENDENTS; numEmployees++; employeeBenefits = new Benefits(); } public Employee(string firstname, string lastname, char gender, int dependents, double annualsalary, Benefits employeeBenefits) { Firstname = firstname; Lastname = lastname; AnnualSalary = annualsalary; Gender = gender; Dependents = dependents; EmployeeBenefits = employeeBenefits; numEmployees++; } public Benefits EmployeeBenefits { get { return employeeBenefits; } set { if (value == null) employeeBenefits = new Benefits(); else employeeBenefits = value; } } public Employee(string employeeType) : this() { EmployeeType = employeeType; } public string Firstname { get { return firstName; } set { if (String.IsNullOrEmpty(value)) firstName = DEFAULT_NAME; else firstName = value; } } public string Lastname { get { return lastName; } set { if (String.IsNullOrEmpty(value)) lastName = DEFAULT_NAME; else lastName = value; } } public double AnnualSalary { get { return annualSalary; } set { if (value > MIN_SALARY & value < MAX_SALARY) annualSalary = value; else if (value = MIN_DEPENDENTS & value <= MAX_DEPENDENTS) dependents = value; else if (value < MIN_DEPENDENTS) dependents = MIN_DEPENDENTS; else dependents = MAX_DEPENDENTS; } } public static int NumEmployees { get { return numEmployees; } } public string EmployeeName { get { return firstName + " " + lastName; } } public string EmployeeType { get { return employeeType; } set { if (String.IsNullOrEmpty(value)) employeeType = DEFAULT_TYPE; else employeeType = value; } } public double CalculatePay() { return annualSalary / 52; } public double CalculatePay(double modifiedSalary) { AnnualSalary = modifiedSalary; return AnnualSalary / 52; } public override string ToString() { string output; output = "\n============ Employee Information ============"; output += "\n\t Type:\t" + employeeType; output += "\n\t Name:\t" + firstName + " " + lastName; output += "\n\t Gender:\t" + gender; output += "\n\t Dependents:\t" + dependents; output += "\n\tAnnual Salary:\t" + annualSalary.ToString("C2"); output += "\n\t Weekly Pay:\t" + CalculatePay().ToString("C2"); output += "\n\t" + employeeBenefits.ToString(); return output; } } 

}

传递给方法所需的所有类型必须至少与该方法一样可访问。 如果Employee是私有或内部类,则无法从该类/程序集外部传递给此方法。

Employee公开,它应该工作。

Employee类型应该不比CollectEmployeeInfo更易于访问。

所以Employee应该被定义为“至少” public