跟踪参数和方法之间的可访问性

时间:2015-04-16 11:10:04

标签: c#

我通读了THISTHIS

我发现很难跟踪此代码中的辅助功能。

这是错误:

  

错误1可访问性不一致:参数类型'LifeWorxWS.QLINKInstructionDetail.InstructionType'比方法'LifeWorxWS.QLINKInstructionDetail.QLINK_Submit_Instruction(LifeWorxWS.QLINKInstructionDetail.InstructionType,string,string,string,string,string,string,string,double)更难访问,string,string)'C:\ Projects \ Sub version workspaces \ N2A \ LifeWorxWS \ LifeWorxWS \ QLINK \ QLINKInterfaces.cs 163 35 LifeWorxWS

在QLINKINterfaces.cs中,这是代码:

    public class QLINKInstructionDetail
{
    #region "Submit Instructions"
    public QLINKInstruction QLINK_Submit_New_Instruction(string pstrSalaryMonth, string pstrPayrollCode, string pstrEmployeeNr, string pstrSurname, string pstrInitials, string pstrRSAIDNr, string pstrReferenceNr, double pdblAmount, string pstrStartDate)
    {
        try
        {
            //Call SubmitInstruction
            QLINKInstruction lobjQLINKInstructionDC = new QLINKInstruction();
            lobjQLINKInstructionDC = QLINK_Submit_Instruction(InstructionType.QADD, pstrSalaryMonth, pstrPayrollCode, pstrEmployeeNr, pstrSurname, pstrInitials, pstrRSAIDNr, pstrReferenceNr, pdblAmount, pstrStartDate, "");

            //return datacontract as populated return values
            return lobjQLINKInstructionDC;
        }
        catch (Exception ex)
        { return ""; }

    }
    internal QLINKInstruction QLINK_Submit_Instruction(InstructionType penmInstructionType, string pstrSalaryMonth, string pstrPayrollCode, string pstrEmployeeNr, string pstrSurname, string pstrInitials, string pstrRSAIDNr, string pstrReferenceNr, double pdblAmount, string pstrStartDate, string pstrEndDate)
    {
        try
        {
            //Get Header
            string lstrHeader = GetHeader();

            //Get Detail
            string lstrDetail = GetDetailTransaction();

            string lstrCombinedXMLInstruction = "";

            lstrCombinedXMLInstruction = "<QLINK>" + Environment.NewLine;
            lstrCombinedXMLInstruction += lstrHeader + Environment.NewLine;
            lstrCombinedXMLInstruction += lstrDetail + Environment.NewLine;
            lstrCombinedXMLInstruction += "</QLINK>" + Environment.NewLine;

            //Submit packet - page 15 to QLINK and get/handle response


            //set return values
            QLINKInstruction lobjQLINKInstructionDC = new QLINKInstruction();

            //return datacontract as populated return values
            return lobjQLINKInstructionDC;
        }
        catch (Exception ex)
        { return ""; }

    }

    #endregion "Submit Instructions"

    #region "Enums"
    private enum InstructionType
    {
        QADD = 1,
        QUPD = 2,
        QDEL = 3
    }

    #endregion "Enums"

}

我理解它的方式应该不会有问题因为QLINKInstructionDetail可以被同一个程序集中的任何其他代码访问,QLINK_Submit_Instruction可以被同一程序集中的任何代码访问InstructionType QLINKInstructionDetail 1}}只能由同一个类中的代码访问,并且位于QLINK_Submit_Instruction {{1}}所在的位置。

显然不是正确的理解(否则错误不会出现)。 有人可以在这段代码中指出我做错了吗?

1 个答案:

答案 0 :(得分:0)

InstructionType被宣泄为private,您必须将其声明为internalpublic。该类型必须用于调用方法,因为它用作方法QLINK_Submit_Instruction的参数。

否则你必须将方法视为私有。