試圖在一個項目上工作,但不斷收到此錯誤。不一致的可訪問性錯誤C#
錯誤1可訪問性不一致:參數類型 'GICT_Project.IObjects' 比方法更少可訪問的 'GICT_Project.DatabaseService.Insert(GICT_Project.IObjects)' E:\ GICT_Project \ GICT_Project \ DatabaseService.cs 86 28 GICT_Project
不知道什麼是錯的。試圖改變東西,但沒有骰子。
這裏是有問題的代碼:
public static void Insert(IObjects classType) //insert tool data
{
string query = "";
string type = (classType.GetType()).ToString();
switch (type) {
case "Tools":
query = "INSERT INTO group2.Tools (ToolID, ToolName, Quantity) VALUES(" + classType.GetSqlInfo() + ")";
break;
case "Service":
query = "INSERT INTO group2.Services (ServiceID, ServName, ToolID) VALUES(" + classType.GetSqlInfo() + ")";
break;
case "Location":
query = "INSERT INTO group2.Location (LocationID, Location, Features) VALUES(" + classType.GetSqlInfo() + ")";
break;
case "Appointments":
query = "INSERT INTO group2.Appointments (AppointmentID, CustomerID, ServiceID, LocationID, EmployeeID) VALUES(" + classType.GetSqlInfo() + ")";
break;
case "Employee":
query = "INSERT INTO group2.Employee (EmployeeID, EmpName, EmpBirthday, EmpAddress, LocationID) VALUES(" + classType.GetSqlInfo() + ")";
break;
case "Customer":
query = "INSERT INTO group2.Customer (CustomerID, CusName, CusBirthday, CusAddress) VALUES(" + classType.GetSqlInfo() + ")";
break;
case "Skills":
query = "INSERT INTO group2.Skills (SkillID, SkillName) VALUES(" + classType.GetSqlInfo() + ")";
break;
//many to many tables need to create rows on connecting tables when initialised
}
InsertQuery(query);
}
這是單獨的類:
interface IObjects
{
string GetSqlInfo();
int GetId();
void InsertData();
}
如果你不告訴編譯器給你的類/接口/什麼的可訪問性,它將默認爲'internal'。所以你的界面是內部的,而你的課堂是公開的。 – DavidG
確定它不是內部的(對於類和接口當然)? @DavidG –
@PatrickHofman呃,你是對的!無論哪種方式,這是一個騙局。 – DavidG