2015-07-10 22 views
-3

我有這個「EmployeeData.Employees」不包含一個構造函數6變元

錯誤問題1「EmployeeData.Employees」不包含一個構造 需要6個參數C:\用戶\約翰\的文檔\ Visual Studio的 2012 \項目\ 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"); 

     } 
    } 

} 
+1

這意味着'僱員'類沒有一個構造函數需要6個參數。 –

+0

,因爲你可以看到它有 – user3289317

+0

這是通過在構造函數中添加缺少的'public'修飾符來解決的。 –

回答

0

嘗試將public訪問修飾符添加到您的構造函數中。

0

在您的主要功能中,您將「員工」拼錯爲「員工」。我建議將該類重命名爲「員工」,因爲它更有意義 - 您一次創建一個。

編輯:也許性別周圍的單引號也是不必要的。試着'米'而不是'米'。

相關問題