Pregunta

Let say I have this class and all method are properly implemented (in this case I think the implementation is irrevelant to the question).

static class ZedGraphHelper
{
    public static ZedGraph.ZedGraphControl GetZedGraph(Guid config, Guid equip)
    { throw new NotImplementedException; }

    //This method here is the faulty one
    public static void AdjustGraphParam(ZedGraph.ZedGraphControl zGraph, RP.mgrRPconfigGraph mgr)
    { throw new NotImplementedException; }

    public static void FillGraph(ZedGraph.ZedGraphControl zGraph, Guid config, Guid equip, Guid form)
    { throw new NotImplementedException; }

    public static void FillGraph(ZedGraph.ZedGraphControl zGraph,  Shadow.dsEssais.FMdocDataTable dtDoc, Shadow.dsEssais.FMchampFormDataTable dtChamp)
    { throw new NotImplementedException; }

    public static void LoadDoc(Shadow.dsEssais.FMdocDataTable dtDoc, Guid equip, Guid form)
    { throw new NotImplementedException; }

    public static double LoadDonnee(Guid champ, Guid doc)
    { throw new NotImplementedException; }

    public static SqlDataReader ReadDonnee(Guid champ, Guid doc)
    { throw new NotImplementedException; }
}

this code compile fine and set no error. How ever if I change the class declaration from

static class ZedGraphHelper

to

public static class ZedGraphHelper

I got the folowing error message : Inconsistent accessibility: parameter type 'RP.mgrRPconfigGraph' is less accessible than method 'Shadow.ZedGraphHelper.AdjustGraphParam(ZedGraph.ZedGraphControl, RP.mgrRPconfigGraph)' this method is present in the class declaration I have included just here. The method is public static void.

Why am I getting this error? And does the public change anything in the code behaviour?

¿Fue útil?

Solución

Yes RP.mgrRPconfigGraph is an internal type(or less accessible than that). So when you change ZedGraphHelper to public it exposes its methods as public which are all marked as public. which you can't do for AdjustGraphParam method since parameter is internal type

Either make the method internal

internal static void AdjustGraphParam(ZedGraph.ZedGraphControl zGraph, RP.mgrRPconfigGraph mgr)
{ throw new NotImplementedException; }

Or mark the RP.mgrRPconfigGraph type as public

Otros consejos

The default access modifier for a class is internal. this means that, if you omit the access modifier, the class will be internal.

If you change the class to be public, you get this error because one of the parameters of the methods that exists in your class is an internal type.

This means that your class cannot be public, since it depends on an internal type, which is less accessible than your class. (The internal type can only be used in the assembly in which it has been declared while the public class can be used everywhere).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top