& # 39; EmployeeData.Employees& # 39;不包含带6个参数的构造函数

本文关键字:参数 6个 构造函数 Employees EmployeeData 包含带 | 更新日期: 2023-09-27 18:01:55

我有这个问题

错误1 'EmployeeData。Employees不包含构造函数C:'Users'John'documents'visual studio2012 ' ConsoleApplication2 ' ConsoleApplication1 ' '项目员工Data.cs 65 26 EmployeeData

(http://pastebin.com/embed_js.php?i=0fbwpthp)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeData
{
      public class Employees
    {
        private string firstName;
        private string lastName;
        private int age;
        private char gender;
        private string PI;
        private string uniEmployeeNum;
       Employees(){}
        Employees(string firstName,
                 string lastName,
                 int age,
                 char gender,
                 string PI,
                 string uniEmployeeNum)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.age = age;
            this.gender = gender;
            this.PI = PI;
            this.uniEmployeeNum = uniEmployeeNum;
        }
        public string FirstName()
        {
            return firstName;
        }
        public string LastName()
        {
            return lastName;
        }
        public string PII()
        {
            return PI;
        }
        public string UniEmployeeNum()
        {
            return uniEmployeeNum;
        }
        public int Age()
        {
            return age;
        }
        public char Gender()
        {
            return gender;
        }
    }

    class EmployeeData
    {
        void emp()
        {
            Employees man = new Employees("John", "Johnny", 19, 'm', "68161863181686", "6846684644");
        }
        static void Main(string[] args)
        {
           // Employee man = new Employee("John", "Johnny", 19, 'm', "68161863181686", "6846684644");
        }
    }
}

& # 39; EmployeeData.Employees& # 39;不包含带6个参数的构造函数

尝试在构造函数中添加public访问修饰符

在主函数中,您将"Employees"拼错为"Employee"。我建议将类重命名为"Employee",因为这样更有意义——一次创建一个。

edit:也许性别周围的单引号也是不必要的。用'm'代替'm'。